From 1d7e6f5dcb29535cde9b7dfd6998d7889baf835b Mon Sep 17 00:00:00 2001 From: Robert Garbee Date: Tue, 17 Jul 2012 13:23:48 -0600 Subject: first work on PWM input to TeleScience, 'p' command displays timer 1 --- src/product/ao_telescience.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/product') diff --git a/src/product/ao_telescience.c b/src/product/ao_telescience.c index 45b6d40e..2d594d7f 100644 --- a/src/product/ao_telescience.c +++ b/src/product/ao_telescience.c @@ -16,6 +16,7 @@ */ #include "ao.h" +#include "ao_pwmin.h" int main(void) @@ -34,6 +35,7 @@ main(void) ao_usb_init(); ao_adc_init(); ao_log_single_init(); + ao_pwmin_init(); ao_start_scheduler(); return 0; } -- cgit v1.2.3 From f34f0ac7f355149446374a4c82dbf004919bc2dd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Oct 2012 22:21:04 -0700 Subject: altos: Add telescience-pwm product Split out special PWM-sampling telescience product Signed-off-by: Keith Packard --- src/avr/ao_adc_avr.c | 2 +- src/avr/ao_pwmin.h | 2 + src/product/ao_telescience.c | 4 ++ src/telescience-pwm/.gitignore | 2 + src/telescience-pwm/Makefile | 116 +++++++++++++++++++++++++++++++++++++++++ src/telescience-v0.1/Makefile | 1 - 6 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 src/telescience-pwm/.gitignore create mode 100644 src/telescience-pwm/Makefile (limited to 'src/product') diff --git a/src/avr/ao_adc_avr.c b/src/avr/ao_adc_avr.c index 739a6d4a..231512b2 100644 --- a/src/avr/ao_adc_avr.c +++ b/src/avr/ao_adc_avr.c @@ -94,7 +94,7 @@ ISR(ADC_vect) value = ADCL; value |= (ADCH << 8); ao_data_ring[ao_data_head].adc.adc[ao_adc_channel] = value; - if (++ao_adc_channel < NUM_ADC - 1) + if (++ao_adc_channel < NUM_ADC - HAS_ICP3_COUNT) ao_adc_start(); else { #if HAS_ICP3_COUNT diff --git a/src/avr/ao_pwmin.h b/src/avr/ao_pwmin.h index bbab4ddc..8097d399 100644 --- a/src/avr/ao_pwmin.h +++ b/src/avr/ao_pwmin.h @@ -16,3 +16,5 @@ */ void ao_pwmin_init(void); + +extern volatile __data uint16_t ao_icp3_count; diff --git a/src/product/ao_telescience.c b/src/product/ao_telescience.c index 2d594d7f..d448d318 100644 --- a/src/product/ao_telescience.c +++ b/src/product/ao_telescience.c @@ -16,7 +16,9 @@ */ #include "ao.h" +#if HAS_ICP3_COUNT #include "ao_pwmin.h" +#endif int main(void) @@ -35,7 +37,9 @@ main(void) ao_usb_init(); ao_adc_init(); ao_log_single_init(); +#if HAS_ICP3_COUNT ao_pwmin_init(); +#endif ao_start_scheduler(); return 0; } diff --git a/src/telescience-pwm/.gitignore b/src/telescience-pwm/.gitignore new file mode 100644 index 00000000..dfccadf8 --- /dev/null +++ b/src/telescience-pwm/.gitignore @@ -0,0 +1,2 @@ +telescience-v0.1* +ao_product.h diff --git a/src/telescience-pwm/Makefile b/src/telescience-pwm/Makefile new file mode 100644 index 00000000..43d77e2e --- /dev/null +++ b/src/telescience-pwm/Makefile @@ -0,0 +1,116 @@ +# +# AltOS build +# +# +vpath % ..:../core:../product:../drivers:../avr +vpath ao-make-product.5c ../util + +MCU=atmega32u4 +DUDECPUTYPE=m32u4 +#PROGRAMMER=stk500v2 -P usb +PROGRAMMER=usbtiny +LOADCMD=avrdude +LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: +CC=avr-gcc +OBJCOPY=avr-objcopy + +ifndef VERSION +include ../Version +endif + +INC = \ + ao.h \ + ao_arch.h \ + ao_usb.h \ + ao_pins.h \ + ao_product.h + +# +# Common AltOS sources +# +TELESCIENCE_STORAGE= \ + ao_m25.c \ + ao_spi_usart.c \ + ao_storage.c + +TELESCIENCE_LOG= \ + ao_log_single.c \ + ao_log_telescience.c + +ALTOS_SRC = \ + ao_clock.c \ + ao_cmd.c \ + ao_mutex.c \ + ao_panic.c \ + ao_product.c \ + ao_stdio.c \ + ao_task.c \ + ao_timer.c \ + ao_led.c \ + ao_avr_stdio.c \ + ao_romconfig.c \ + ao_usb_avr.c \ + ao_adc_avr.c \ + ao_science_slave.c \ + ao_spi_slave.c \ + ao_pwmin.c \ + $(TELESCIENCE_STORAGE)\ + $(TELESCIENCE_LOG) + +PRODUCT=TeleScience-PWM +MCU=atmega32u4 +PRODUCT_DEF=-DTELESCIENCE -DTELESCIENCE_PWM +IDPRODUCT=0x0011 +CFLAGS = $(PRODUCT_DEF) -I. -I../avr -I../core -I.. +CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O3 -mcall-prologues -DAVR + +NICKLE=nickle + +PROG=telescience-pwm + +SRC=$(ALTOS_SRC) ao_telescience.c +OBJ=$(SRC:.c=.o) + +V=0 +# The user has explicitly enabled quiet compilation. +ifeq ($(V),0) +quiet = @printf " $1 $2 $@\n"; $($1) +endif +# Otherwise, print the full command line. +quiet ?= $($1) + +all: $(PROG) + +CHECK=sh ../util/check-avr-mem + +$(PROG): Makefile $(OBJ) + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) + $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1) + +$(PROG).hex: $(PROG) + avr-size $(PROG) + $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@ + + +load: $(PROG).hex + $(LOADCMD) $(LOADARG)$(PROG).hex + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +ao_product.o: ao_product.c ao_product.h + +%.o : %.c $(INC) + $(call quiet,CC) -c $(CFLAGS) $< + +distclean: clean + +clean: + rm -f *.o $(PROG) $(PROG).hex + rm -f ao_product.h + +install: + +uninstall: + +$(OBJ): ao_product.h $(INC) diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile index 5542913d..d24128ef 100644 --- a/src/telescience-v0.1/Makefile +++ b/src/telescience-v0.1/Makefile @@ -53,7 +53,6 @@ ALTOS_SRC = \ ao_adc_avr.c \ ao_science_slave.c \ ao_spi_slave.c \ - ao_pwmin.c \ $(TELESCIENCE_STORAGE)\ $(TELESCIENCE_LOG) -- cgit v1.2.3 From 1d3ab47d82fe005ab6854386c0ffa5771ee49bf6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 8 Apr 2013 16:48:40 -0700 Subject: altos: Create telebt-v1.0 product. Remove old telebt products Signed-off-by: Keith Packard --- src/Makefile | 2 +- src/drivers/ao_btm.c | 2 +- src/product/Makefile.telebt | 97 --------------------------------------------- src/product/ao_telebt.c | 61 ---------------------------- src/telebt-v0.0/.gitignore | 2 - src/telebt-v0.0/.sdcdbrc | 1 - src/telebt-v0.0/Makefile | 9 ----- src/telebt-v0.1/.gitignore | 2 - src/telebt-v0.1/.sdcdbrc | 2 - src/telebt-v0.1/Makefile | 21 ---------- src/telebt-v1.0/.gitignore | 2 + src/telebt-v1.0/.sdcdbrc | 2 + src/telebt-v1.0/Makefile | 96 ++++++++++++++++++++++++++++++++++++++++++++ src/telebt-v1.0/ao_pins.h | 89 +++++++++++++++++++++++++++++++++++++++++ src/telebt-v1.0/ao_telebt.c | 40 +++++++++++++++++++ 15 files changed, 231 insertions(+), 197 deletions(-) delete mode 100644 src/product/Makefile.telebt delete mode 100644 src/product/ao_telebt.c delete mode 100644 src/telebt-v0.0/.gitignore delete mode 100644 src/telebt-v0.0/.sdcdbrc delete mode 100644 src/telebt-v0.0/Makefile delete mode 100644 src/telebt-v0.1/.gitignore delete mode 100644 src/telebt-v0.1/.sdcdbrc delete mode 100644 src/telebt-v0.1/Makefile create mode 100644 src/telebt-v1.0/.gitignore create mode 100644 src/telebt-v1.0/.sdcdbrc create mode 100644 src/telebt-v1.0/Makefile create mode 100644 src/telebt-v1.0/ao_pins.h create mode 100644 src/telebt-v1.0/ao_telebt.c (limited to 'src/product') diff --git a/src/Makefile b/src/Makefile index 9e31e3ea..d91a235a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ SDCCDIRS=\ telemetrum-v1.2 telemetrum-v1.1 telemetrum-v1.0 \ teledongle-v0.2 teledongle-v0.1 \ telemini-v1.0 telenano-v0.1 \ - telebt-v0.0 telebt-v0.1 \ + telebt-v1.0 \ telemetrum-v0.1-sky telemetrum-v0.1-sirf \ telelaunch-v0.1 tidongle test \ teleterra-v0.2 teleshield-v0.1 \ diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index de1f31a3..3b6028a0 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -302,7 +302,7 @@ ao_btm(void) while (!ao_btm_connected) ao_sleep(&ao_btm_connected); while (ao_btm_connected) { - ao_led_for(AO_LED_GREEN, AO_MS_TO_TICKS(20)); + ao_led_for(AO_BT_LED, AO_MS_TO_TICKS(20)); ao_delay(AO_SEC_TO_TICKS(3)); } } diff --git a/src/product/Makefile.telebt b/src/product/Makefile.telebt deleted file mode 100644 index fd52cec4..00000000 --- a/src/product/Makefile.telebt +++ /dev/null @@ -1,97 +0,0 @@ -# -# TeleBT build file -# -# Define TELEBT_VER, TELEBT_DEF, TELEBT_INC and TELEBT_SRC -# and include this file - -vpath %.c ..:../core:../cc1111:../drivers:../product -vpath %.h ..:../core:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h \ - $(TELEBT_INC) - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_gps_print.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_state.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - ao_btm.c - -PRODUCT_SRC = \ - ao_telebt.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) \ - $(TELEBT_SRC) - -PROGNAME = telebt-v$(TELEBT_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleBT-v$(TELEBT_VER) -PRODUCT_DEF=-DTELEBT_V_$(TELEBT_DEF) -IDPRODUCT=0x000e - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/product/ao_telebt.c b/src/product/ao_telebt.c deleted file mode 100644 index 46c63418..00000000 --- a/src/product/ao_telebt.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -#if HAS_LOG -__code uint8_t ao_log_format = AO_LOG_FORMAT_NONE; /* until we actually log stuff */ -#endif - -void -main(void) -{ - ao_clock_init(); - - /* Turn on the LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - ao_timer_init(); -#if HAS_BEEP - ao_beep_init(); -#endif - ao_cmd_init(); -#if HAS_EEPROM - ao_spi_init(); - ao_storage_init(); -#endif - ao_usb_init(); - ao_monitor_init(); -#if HAS_LOG - ao_report_init(); -#endif - ao_radio_init(); - ao_packet_master_init(); - ao_btm_init(); -#if HAS_LOG - ao_log_single_init(); -#endif -#if HAS_DBG - ao_dbg_init(); -#endif -#if HAS_AES - ao_aes_init(); - ao_radio_cmac_init(); -#endif - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/telebt-v0.0/.gitignore b/src/telebt-v0.0/.gitignore deleted file mode 100644 index 1acfbfcc..00000000 --- a/src/telebt-v0.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telebt-* -ao_product.h diff --git a/src/telebt-v0.0/.sdcdbrc b/src/telebt-v0.0/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/telebt-v0.0/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/telebt-v0.0/Makefile b/src/telebt-v0.0/Makefile deleted file mode 100644 index e89639ab..00000000 --- a/src/telebt-v0.0/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# TeleBT v0.0 build -# - -TELEBT_VER=0.0 -TELEBT_DEF=0_0 - -include ../product/Makefile.telebt - diff --git a/src/telebt-v0.1/.gitignore b/src/telebt-v0.1/.gitignore deleted file mode 100644 index 1acfbfcc..00000000 --- a/src/telebt-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telebt-* -ao_product.h diff --git a/src/telebt-v0.1/.sdcdbrc b/src/telebt-v0.1/.sdcdbrc deleted file mode 100644 index b9f6129c..00000000 --- a/src/telebt-v0.1/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../core:../drivers:. - diff --git a/src/telebt-v0.1/Makefile b/src/telebt-v0.1/Makefile deleted file mode 100644 index 90cd3cac..00000000 --- a/src/telebt-v0.1/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# -# TeleBT v0.1 build -# - -TELEBT_VER=0.1 -TELEBT_DEF=0_1 - -TELEBT_INC = \ - ao_25lc1024.h - -TELEBT_SRC = \ - ao_beep.c \ - ao_log_single.c \ - ao_log_telem.c \ - ao_report.c \ - ao_spi.c \ - ao_storage.c \ - ao_m25.c - -include ../product/Makefile.telebt - diff --git a/src/telebt-v1.0/.gitignore b/src/telebt-v1.0/.gitignore new file mode 100644 index 00000000..1acfbfcc --- /dev/null +++ b/src/telebt-v1.0/.gitignore @@ -0,0 +1,2 @@ +telebt-* +ao_product.h diff --git a/src/telebt-v1.0/.sdcdbrc b/src/telebt-v1.0/.sdcdbrc new file mode 100644 index 00000000..b9f6129c --- /dev/null +++ b/src/telebt-v1.0/.sdcdbrc @@ -0,0 +1,2 @@ +--directory=../cc1111:../product:../core:../drivers:. + diff --git a/src/telebt-v1.0/Makefile b/src/telebt-v1.0/Makefile new file mode 100644 index 00000000..1a3f1c80 --- /dev/null +++ b/src/telebt-v1.0/Makefile @@ -0,0 +1,96 @@ +# +# TeleBT build file +# + +TELEBT_VER=1.0 +TELEBT_DEF=1_0 + +vpath %.c ..:../core:../cc1111:../drivers:../product +vpath %.h ..:../core:../cc1111:../drivers:../product +vpath ao-make-product.5c ../util + +ifndef VERSION +include ../Version +endif + +INC = \ + ao.h \ + ao_pins.h \ + ao_arch.h \ + ao_arch_funcs.h \ + cc1111.h \ + ao_product.h + +CORE_SRC = \ + ao_cmd.c \ + ao_config.c \ + ao_gps_print.c \ + ao_monitor.c \ + ao_mutex.c \ + ao_panic.c \ + ao_state.c \ + ao_stdio.c \ + ao_task.c \ + ao_freq.c + +CC1111_SRC = \ + ao_dbg.c \ + ao_dma.c \ + ao_led.c \ + ao_packet.c \ + ao_packet_master.c \ + ao_radio.c \ + ao_romconfig.c \ + ao_serial.c \ + ao_string.c \ + ao_timer.c \ + ao_usb.c \ + _bp.c + +DRIVER_SRC = \ + ao_btm.c + +PRODUCT_SRC = \ + ao_telebt.c + +SRC = \ + $(CORE_SRC) \ + $(CC1111_SRC) \ + $(DRIVER_SRC) \ + $(PRODUCT_SRC) + +PROGNAME = telebt-v$(TELEBT_VER) +PROG = $(PROGNAME)-$(VERSION).ihx +PRODUCT=TeleBT-v$(TELEBT_VER) +PRODUCT_DEF=-DTELEBT_V_$(TELEBT_DEF) +IDPRODUCT=0x000e + +include ../cc1111/Makefile.cc1111 + +NICKLE=nickle +CHECK_STACK=sh ../util/check-stack + +V=0 +# The user has explicitly enabled quiet compilation. +ifeq ($(V),0) +quiet = @printf " $1 $2 $@\n"; $($1) +endif +# Otherwise, print the full command line. +quiet ?= $($1) + +all: $(PROG) + +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. + $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +distclean: clean + +clean: clean-cc1111 + +install: + +uninstall: diff --git a/src/telebt-v1.0/ao_pins.h b/src/telebt-v1.0/ao_pins.h new file mode 100644 index 00000000..b248521d --- /dev/null +++ b/src/telebt-v1.0/ao_pins.h @@ -0,0 +1,89 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +#define HAS_RADIO 1 +#define HAS_FLIGHT 0 +#define HAS_USB 1 +#define HAS_BEEP 0 +#define HAS_SERIAL_1 1 +#define HAS_SERIAL_1_ALT_1 1 +#define HAS_SERIAL_1_ALT_2 0 +#define HAS_SERIAL_1_HW_FLOW 1 +#define USE_SERIAL_1_STDIN 1 +#define DELAY_SERIAL_1_STDIN 1 +#define HAS_ADC 0 +#define HAS_DBG 1 +#define HAS_EEPROM 0 +#define HAS_LOG 0 +#define USE_INTERNAL_FLASH 0 +#define HAS_BTM 1 +#define DBG_ON_P1 1 +#define DBG_ON_P0 0 +#define PACKET_HAS_MASTER 1 +#define PACKET_HAS_SLAVE 0 +#define AO_LED_RED 1 +#define AO_LED_BLUE 2 +#define LEDS_AVAILABLE (AO_LED_RED|AO_LED_BLUE) +#define AO_MONITOR_LED AO_LED_RED +#define AO_BT_LED AO_LED_BLUE +#define BT_LINK_ON_P2 0 +#define BT_LINK_ON_P1 1 +#define BT_LINK_PIN_INDEX 7 +#define BT_LINK_PIN P1_7 +#define HAS_MONITOR 1 +#define LEGACY_MONITOR 0 + +#if DBG_ON_P1 + + #define DBG_CLOCK (1 << 4) /* mi0 */ + #define DBG_DATA (1 << 5) /* mo0 */ + #define DBG_RESET_N (1 << 3) /* c0 */ + + #define DBG_CLOCK_PIN (P1_4) + #define DBG_DATA_PIN (P1_5) + #define DBG_RESET_N_PIN (P1_3) + + #define DBG_PORT_NUM 1 + #define DBG_PORT P1 + #define DBG_PORT_SEL P1SEL + #define DBG_PORT_INP P1INP + #define DBG_PORT_DIR P1DIR + +#endif /* DBG_ON_P1 */ + +#if DBG_ON_P0 + + #define DBG_CLOCK (1 << 3) + #define DBG_DATA (1 << 4) + #define DBG_RESET_N (1 << 5) + + #define DBG_CLOCK_PIN (P0_3) + #define DBG_DATA_PIN (P0_4) + #define DBG_RESET_N_PIN (P0_5) + + #define DBG_PORT_NUM 0 + #define DBG_PORT P0 + #define DBG_PORT_SEL P0SEL + #define DBG_PORT_INP P0INP + #define DBG_PORT_DIR P0DIR + +#endif /* DBG_ON_P0 */ + +#endif /* _AO_PINS_H_ */ diff --git a/src/telebt-v1.0/ao_telebt.c b/src/telebt-v1.0/ao_telebt.c new file mode 100644 index 00000000..89434e7e --- /dev/null +++ b/src/telebt-v1.0/ao_telebt.c @@ -0,0 +1,40 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +void +main(void) +{ + ao_clock_init(); + + /* Turn on the LED until the system is stable */ + ao_led_init(LEDS_AVAILABLE); + ao_led_on(AO_LED_RED); + ao_timer_init(); + ao_cmd_init(); + ao_usb_init(); + ao_monitor_init(); + ao_radio_init(); + ao_packet_master_init(); + ao_btm_init(); +#if HAS_DBG + ao_dbg_init(); +#endif + ao_config_init(); + ao_start_scheduler(); +} -- cgit v1.2.3 From 4551be8b03a795ece94fd303a1f556c63c0a0096 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 24 Mar 2013 15:14:12 -0700 Subject: altos: Call ao_task_init before initializing any drivers When using task queues, the sleep queues must be initialized before any invocation of ao_wakeup or the OS will crash. Just make sure ao_task_init is always invoked early in the task process to get that done. Signed-off-by: Keith Packard --- src/avr-demo/ao_demo.c | 2 + src/product/ao_teledongle.c | 2 + src/product/ao_telelaunch.c | 2 + src/product/ao_telemetrum.c | 2 + src/product/ao_telemini.c | 2 + src/product/ao_telenano.c | 2 + src/product/ao_telepyro.c | 2 + src/product/ao_telescience.c | 2 + src/product/ao_teleterra.c | 2 + src/product/ao_teleterra_0_2.c | 2 + src/product/ao_test.c | 2 + src/product/ao_tidongle.c | 3 + src/spiradio-v0.1/ao_spiradio.c | 2 + src/stm-demo/ao_demo.c | 2 + src/stm-flash/ao_stm_flash.c | 137 ++++++++++++++++++++++++++++++++++ src/teleballoon-v1.1/ao_teleballoon.c | 2 + src/telebt-v1.0/ao_telebt.c | 3 + src/telefire-v0.1/ao_telefire.c | 2 + src/telelco-v0.1/ao_telelco.c | 2 + src/telescience-v0.2/ao_telescience.c | 4 +- src/teleshield-v0.1/ao_teleshield.c | 1 + 21 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 src/stm-flash/ao_stm_flash.c (limited to 'src/product') diff --git a/src/avr-demo/ao_demo.c b/src/avr-demo/ao_demo.c index 756dd0d4..e35babb3 100644 --- a/src/avr-demo/ao_demo.c +++ b/src/avr-demo/ao_demo.c @@ -34,6 +34,8 @@ main(void) { ao_clock_init(); + ao_task_init(); + ao_serial_init(); ao_led_init(LEDS_AVAILABLE); diff --git a/src/product/ao_teledongle.c b/src/product/ao_teledongle.c index 25ebe73e..8bfd8b84 100644 --- a/src/product/ao_teledongle.c +++ b/src/product/ao_teledongle.c @@ -26,6 +26,8 @@ main(void) /* Turn on the LED until the system is stable */ ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); + ao_task_init(); + ao_timer_init(); ao_cmd_init(); ao_usb_init(); diff --git a/src/product/ao_telelaunch.c b/src/product/ao_telelaunch.c index b6e4bfc1..dde66090 100644 --- a/src/product/ao_telelaunch.c +++ b/src/product/ao_telelaunch.c @@ -27,6 +27,8 @@ main(void) ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_beep_init(); diff --git a/src/product/ao_telemetrum.c b/src/product/ao_telemetrum.c index ea77f5af..221498d6 100644 --- a/src/product/ao_telemetrum.c +++ b/src/product/ao_telemetrum.c @@ -42,6 +42,8 @@ main(void) while (P1_3 == 0) ; } + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_beep_init(); diff --git a/src/product/ao_telemini.c b/src/product/ao_telemini.c index 21551ee9..a0d8e18a 100644 --- a/src/product/ao_telemini.c +++ b/src/product/ao_telemini.c @@ -46,6 +46,8 @@ main(void) ; } + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_cmd_init(); diff --git a/src/product/ao_telenano.c b/src/product/ao_telenano.c index d91983d0..77750efd 100644 --- a/src/product/ao_telenano.c +++ b/src/product/ao_telenano.c @@ -28,6 +28,8 @@ main(void) ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_cmd_init(); diff --git a/src/product/ao_telepyro.c b/src/product/ao_telepyro.c index 79454fb7..6f09be64 100644 --- a/src/product/ao_telepyro.c +++ b/src/product/ao_telepyro.c @@ -25,6 +25,8 @@ main(void) PORTE |= (1 << 6); DDRE |= (1 << 6); + ao_task_init(); + ao_avr_stdio_init(); ao_timer_init(); ao_cmd_init(); diff --git a/src/product/ao_telescience.c b/src/product/ao_telescience.c index d448d318..2888c266 100644 --- a/src/product/ao_telescience.c +++ b/src/product/ao_telescience.c @@ -28,6 +28,8 @@ main(void) PORTE |= (1 << 6); DDRE |= (1 << 6); + ao_task_init(); + ao_avr_stdio_init(); ao_timer_init(); ao_cmd_init(); diff --git a/src/product/ao_teleterra.c b/src/product/ao_teleterra.c index d696b914..e739ae0b 100644 --- a/src/product/ao_teleterra.c +++ b/src/product/ao_teleterra.c @@ -26,6 +26,8 @@ main(void) /* Turn on the red LED until the system is stable */ ao_led_init(AO_LED_RED|AO_LED_GREEN); ao_led_on(AO_LED_RED); + ao_task_init(); + ao_timer_init(); ao_beep_init(); ao_cmd_init(); diff --git a/src/product/ao_teleterra_0_2.c b/src/product/ao_teleterra_0_2.c index 68f02596..4f7530f7 100644 --- a/src/product/ao_teleterra_0_2.c +++ b/src/product/ao_teleterra_0_2.c @@ -23,6 +23,8 @@ main(void) { ao_clock_init(); + ao_task_init(); + ao_timer_init(); ao_beep_init(); ao_cmd_init(); diff --git a/src/product/ao_test.c b/src/product/ao_test.c index 14c2eb75..273a73b5 100644 --- a/src/product/ao_test.c +++ b/src/product/ao_test.c @@ -102,6 +102,8 @@ main(void) { ao_clock_init(); + ao_task_init(); + // ao_add_task(&blink_0_task, blink_0); // ao_add_task(&blink_1_task, blink_1); // ao_add_task(&wakeup_task, wakeup); diff --git a/src/product/ao_tidongle.c b/src/product/ao_tidongle.c index cba0b122..b1a96bdd 100644 --- a/src/product/ao_tidongle.c +++ b/src/product/ao_tidongle.c @@ -27,6 +27,9 @@ main(void) /* Turn on the LED until the system is stable */ ao_led_init(AO_LED_RED); ao_led_on(AO_LED_RED); + + ao_task_init(); + ao_timer_init(); ao_cmd_init(); ao_usb_init(); diff --git a/src/spiradio-v0.1/ao_spiradio.c b/src/spiradio-v0.1/ao_spiradio.c index d3647cc7..de9ea706 100644 --- a/src/spiradio-v0.1/ao_spiradio.c +++ b/src/spiradio-v0.1/ao_spiradio.c @@ -25,6 +25,8 @@ main(void) ao_led_init(LEDS_AVAILABLE); + ao_task_init(); + ao_serial_init(); ao_timer_init(); ao_cmd_init(); diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index b82cb735..9ee0be03 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -183,6 +183,8 @@ main(void) { ao_clock_init(); + ao_task_init(); + ao_serial_init(); ao_timer_init(); ao_dma_init(); diff --git a/src/stm-flash/ao_stm_flash.c b/src/stm-flash/ao_stm_flash.c new file mode 100644 index 00000000..df466d85 --- /dev/null +++ b/src/stm-flash/ao_stm_flash.c @@ -0,0 +1,137 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include +#include +#include + +void +ao_panic(uint8_t reason) +{ + for (;;); +} + +void +ao_application(void) +{ + ao_boot_reboot(AO_BOOT_APPLICATION_BASE); +} + +static uint32_t +ao_cmd_hex32(void) +{ + __pdata uint8_t r = ao_cmd_lex_error; + int8_t n; + uint32_t v = 0; + + ao_cmd_white(); + for(;;) { + n = ao_cmd_hexchar(ao_cmd_lex_c); + if (n < 0) + break; + v = (v << 4) | n; + r = ao_cmd_success; + ao_cmd_lex(); + } + if (r != ao_cmd_success) + ao_cmd_status = r; + return v; +} + +void +ao_block_erase(void) +{ + uint32_t addr = ao_cmd_hex32(); + uint32_t *p = (uint32_t *) addr; + + ao_flash_erase_page(p); +} + +void +ao_block_write(void) +{ + uint32_t addr = ao_cmd_hex32(); + uint32_t *p = (uint32_t *) addr; + union { + uint8_t data8[256]; + uint32_t data32[64]; + } u; + uint16_t i; + + if (addr < 0x08002000 || 0x08200000 <= addr) { + puts("Invalid address"); + return; + } + for (i = 0; i < 256; i++) + u.data8[i] = i; + ao_flash_page(p, u.data32); +} + +static void +puthex(uint8_t c) +{ + c &= 0xf; + if (c < 10) + c += '0'; + else + c += 'a' - 10; + putchar (c); +} + +void +ao_block_read(void) +{ + uint32_t addr = ao_cmd_hex32(); + uint8_t *p = (uint8_t *) addr; + uint16_t i; + uint8_t c; + + for (i = 0; i < 256; i++) { + c = *p++; + puthex(c); + puthex(c>>4); + if ((i & 0xf) == 0xf) + putchar('\n'); + } +} + +__code struct ao_cmds ao_flash_cmds[] = { + { ao_application, "a\0Switch to application" }, + { ao_block_erase, "e \0Erase block." }, + { ao_block_write, "W \0Write block. 256 binary bytes follow newline" }, + { ao_block_read, "R \0Read block. Returns 256 bytes" }, + { 0, NULL }, +}; + +int +main(void) +{ + ao_clock_init(); + + ao_task_init(); + + ao_timer_init(); +// ao_dma_init(); + ao_cmd_init(); +// ao_exti_init(); + ao_usb_init(); + + ao_cmd_register(&ao_flash_cmds[0]); + ao_start_scheduler(); + return 0; +} diff --git a/src/teleballoon-v1.1/ao_teleballoon.c b/src/teleballoon-v1.1/ao_teleballoon.c index c8bf7760..867e98ab 100644 --- a/src/teleballoon-v1.1/ao_teleballoon.c +++ b/src/teleballoon-v1.1/ao_teleballoon.c @@ -52,6 +52,8 @@ main(void) while (P1_3 == 0) ; } + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_beep_init(); diff --git a/src/telebt-v1.0/ao_telebt.c b/src/telebt-v1.0/ao_telebt.c index 4a50a9d4..935cde7d 100644 --- a/src/telebt-v1.0/ao_telebt.c +++ b/src/telebt-v1.0/ao_telebt.c @@ -25,6 +25,9 @@ main(void) /* Turn on the LED until the system is stable */ ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); + + ao_task_init(); + ao_timer_init(); ao_cmd_init(); ao_usb_init(); diff --git a/src/telefire-v0.1/ao_telefire.c b/src/telefire-v0.1/ao_telefire.c index cc0f668f..afa09e20 100644 --- a/src/telefire-v0.1/ao_telefire.c +++ b/src/telefire-v0.1/ao_telefire.c @@ -27,6 +27,8 @@ main(void) ao_led_init(LEDS_AVAILABLE); + ao_task_init(); + ao_timer_init(); ao_adc_init(); ao_beep_init(); diff --git a/src/telelco-v0.1/ao_telelco.c b/src/telelco-v0.1/ao_telelco.c index 080a140b..70665ec6 100644 --- a/src/telelco-v0.1/ao_telelco.c +++ b/src/telelco-v0.1/ao_telelco.c @@ -36,6 +36,8 @@ main(void) ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_GREEN); + ao_task_init(); + ao_timer_init(); ao_spi_init(); diff --git a/src/telescience-v0.2/ao_telescience.c b/src/telescience-v0.2/ao_telescience.c index 2fb3186a..74eef8f4 100644 --- a/src/telescience-v0.2/ao_telescience.c +++ b/src/telescience-v0.2/ao_telescience.c @@ -29,9 +29,11 @@ main(void) ao_mpu_init(); #endif - ao_task_init(); ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_GREEN); + + ao_task_init(); + ao_timer_init(); ao_spi_init(); diff --git a/src/teleshield-v0.1/ao_teleshield.c b/src/teleshield-v0.1/ao_teleshield.c index 4c32817a..d602f646 100644 --- a/src/teleshield-v0.1/ao_teleshield.c +++ b/src/teleshield-v0.1/ao_teleshield.c @@ -29,6 +29,7 @@ main(void) /* Turn on the LED until the system is stable */ ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); + ao_task_init(); ao_timer_init(); ao_cmd_init(); ao_spi_init(); -- cgit v1.2.3 From 4a90eec4b8ee4a35711aa74c13b3f30d12c0fe08 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 27 Apr 2013 15:33:04 -0700 Subject: altos/stm: Create per-product flash loaders Split the flash loader prototype into pieces so that each product can build a custom flash loader with very little code. Signed-off-by: Keith Packard --- src/Makefile | 7 +- src/megadongle-v0.1/flash-loader/Makefile | 7 ++ src/megadongle-v0.1/flash-loader/ao_pins.h | 34 +++++++ src/product/ao_flash_pins.h | 40 ++++++++ src/product/ao_flash_task.c | 137 ++++++++++++++++++++++++++ src/product/ao_flash_task.h | 24 +++++ src/stm-flash/ao_stm_flash.c | 152 ----------------------------- src/stm/Makefile-flash.defs | 92 +++++++++++++++++ src/stm/altos-loader.ld | 31 +++--- src/stm/ao_arch.h | 4 + src/stm/ao_flash.h | 27 +++++ src/stm/ao_flash_loader_stm.c | 32 ++++++ src/stm/ao_flash_stm.c | 2 +- src/stm/ao_flash_stm.h | 27 ----- src/stm/ao_flash_stm_pins.h | 43 ++++++++ src/telegps-v0.1/flash-loader/Makefile | 8 ++ src/telegps-v0.1/flash-loader/ao_pins.h | 34 +++++++ src/telemega-v0.1/flash-loader/Makefile | 7 ++ src/telemega-v0.1/flash-loader/ao_pins.h | 34 +++++++ src/telemega-v0.3/flash-loader/Makefile | 8 ++ src/telemega-v0.3/flash-loader/ao_pins.h | 34 +++++++ 21 files changed, 590 insertions(+), 194 deletions(-) create mode 100644 src/megadongle-v0.1/flash-loader/Makefile create mode 100644 src/megadongle-v0.1/flash-loader/ao_pins.h create mode 100644 src/product/ao_flash_pins.h create mode 100644 src/product/ao_flash_task.c create mode 100644 src/product/ao_flash_task.h delete mode 100644 src/stm-flash/ao_stm_flash.c create mode 100644 src/stm/Makefile-flash.defs create mode 100644 src/stm/ao_flash.h create mode 100644 src/stm/ao_flash_loader_stm.c delete mode 100644 src/stm/ao_flash_stm.h create mode 100644 src/stm/ao_flash_stm_pins.h create mode 100644 src/telegps-v0.1/flash-loader/Makefile create mode 100644 src/telegps-v0.1/flash-loader/ao_pins.h create mode 100644 src/telemega-v0.1/flash-loader/Makefile create mode 100644 src/telemega-v0.1/flash-loader/ao_pins.h create mode 100644 src/telemega-v0.3/flash-loader/Makefile create mode 100644 src/telemega-v0.3/flash-loader/ao_pins.h (limited to 'src/product') diff --git a/src/Makefile b/src/Makefile index 90a74166..5ae61a00 100644 --- a/src/Makefile +++ b/src/Makefile @@ -29,7 +29,12 @@ AVRDIRS=\ telescience-v0.1 telescience-pwm telepyro-v0.1 micropeak ARMDIRS=\ - telemega-v0.1 telemega-v0.3 megadongle-v0.1 stm-bringup stm-demo telelco-v0.1 \ + telemega-v0.1 telemega-v0.1/flash-loader \ + telemega-v0.3 telemega-v0.3/flash-loader \ + megadongle-v0.1 megadongle-v0.1/flash-loader \ + telegps-v0.1 telegps-v0.1/flash-loader \ + stm-bringup stm-demo telelco-v0.1 \ + telelco-v0.2 telelco-v0.2/flash-loader \ telescience-v0.2 ifneq ($(shell which sdcc),) diff --git a/src/megadongle-v0.1/flash-loader/Makefile b/src/megadongle-v0.1/flash-loader/Makefile new file mode 100644 index 00000000..adea5786 --- /dev/null +++ b/src/megadongle-v0.1/flash-loader/Makefile @@ -0,0 +1,7 @@ +# +# AltOS flash loader build +# + +TOPDIR=../.. +HARDWARE=megadongle-v0.1 +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/megadongle-v0.1/flash-loader/ao_pins.h b/src/megadongle-v0.1/flash-loader/ao_pins.h new file mode 100644 index 00000000..1af92f13 --- /dev/null +++ b/src/megadongle-v0.1/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Companion port cs_companion0 PD0 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiod +#define AO_BOOT_APPLICATION_PIN 0 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#endif /* _AO_PINS_H_ */ diff --git a/src/product/ao_flash_pins.h b/src/product/ao_flash_pins.h new file mode 100644 index 00000000..b774df6d --- /dev/null +++ b/src/product/ao_flash_pins.h @@ -0,0 +1,40 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_FLASH_PINS_H_ +#define _AO_FLASH_PINS_H_ + +/* Common definitions for the USB flash loader */ + +#define HAS_TASK_QUEUE 0 + +#define HAS_USB 1 +#define USE_USB_STDIO 0 +#define HAS_BEEP 0 +#define HAS_TASK 0 +#define HAS_ECHO 0 +#define HAS_TICK 0 + +#define PACKET_HAS_SLAVE 0 + +#define HAS_TASK_INFO 0 +#define HAS_VERSION 0 + +#define AO_BOOT_CHAIN 1 +#define AO_BOOT_PIN 1 + +#endif /* _AO_FLASH_PINS_H_ */ diff --git a/src/product/ao_flash_task.c b/src/product/ao_flash_task.c new file mode 100644 index 00000000..fdc4d0aa --- /dev/null +++ b/src/product/ao_flash_task.c @@ -0,0 +1,137 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include +#include +#include +#include + +void +ao_panic(uint8_t reason) +{ +} + +void +ao_put_string(__code char *s) +{ + char c; + while ((c = *s++)) { + if (c == '\n') + ao_usb_putchar('\r'); + ao_usb_putchar(c); + } +} + +static void +ao_application(void) +{ + ao_boot_reboot(AO_BOOT_APPLICATION_BASE); +} + +static uint32_t +ao_get_hex32(void) +{ + int8_t n; + uint32_t v = 0; + + for (;;) { + n = ao_usb_getchar(); + if (n != ' ') + break; + } + for(;;) { + if ('0' <= n && n <= '9') + n = n - '0'; + else if ('a' <= n && n <= 'f') + n = n - ('a' - 10); + else if ('A' <= n && n <= 'F') + n = n - ('A' - 10); + else + break; + v = (v << 4) | n; + n = ao_usb_getchar(); + } + return v; +} + +static void +ao_block_erase(void) +{ + uint32_t addr = ao_get_hex32(); + uint32_t *p = (uint32_t *) addr; + + ao_flash_erase_page(p); +} + +static void +ao_block_write(void) +{ + uint32_t addr = ao_get_hex32(); + uint32_t *p = (uint32_t *) addr; + union { + uint8_t data8[256]; + uint32_t data32[64]; + } u; + uint16_t i; + + if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) { + ao_put_string("Invalid address\n"); + return; + } + for (i = 0; i < 256; i++) + u.data8[i] = ao_usb_getchar(); + ao_flash_page(p, u.data32); +} + +static void +ao_block_read(void) +{ + uint32_t addr = ao_get_hex32(); + uint8_t *p = (uint8_t *) addr; + uint16_t i; + uint8_t c; + + for (i = 0; i < 256; i++) { + c = *p++; + ao_usb_putchar(c); + } +} + +static void +ao_show_version(void) +{ + ao_put_string("altos-loader"); + ao_put_string("\nmanufacturer "); ao_put_string(ao_manufacturer); + ao_put_string("\nproduct "); ao_put_string(ao_product); + ao_put_string("\nsoftware-version "); ao_put_string(ao_version); + ao_put_string("\n"); +} + +void +ao_flash_task(void) { + for (;;) { + ao_usb_flush(); + switch (ao_usb_getchar()) { + case 'v': ao_show_version(); break; + case 'a': ao_application(); break; + case 'X': ao_block_erase(); break; + case 'W': ao_block_write(); break; + case 'R': ao_block_read(); break; + } + } +} diff --git a/src/product/ao_flash_task.h b/src/product/ao_flash_task.h new file mode 100644 index 00000000..0a2fbb35 --- /dev/null +++ b/src/product/ao_flash_task.h @@ -0,0 +1,24 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_FLASH_TASK_H_ +#define _AO_FLASH_TASK_H_ + +void +ao_flash_task(void); + +#endif /* _AO_FLASH_TASK_H_ */ diff --git a/src/stm-flash/ao_stm_flash.c b/src/stm-flash/ao_stm_flash.c deleted file mode 100644 index f8580735..00000000 --- a/src/stm-flash/ao_stm_flash.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include -#include -#include - -void -ao_panic(uint8_t reason) -{ - for (;;); -} - -void -ao_put_string(__code char *s) -{ - char c; - while ((c = *s++)) { - if (c == '\n') - ao_usb_putchar('\r'); - ao_usb_putchar(c); - } -} - -void -ao_application(void) -{ - ao_boot_reboot(AO_BOOT_APPLICATION_BASE); -} - -static uint32_t -ao_get_hex32(void) -{ - int8_t n; - uint32_t v = 0; - - for (;;) { - n = ao_usb_getchar(); - if (n != ' ') - break; - } - for(;;) { - if ('0' <= n && n <= '9') - n = n - '0'; - else if ('a' <= n && n <= 'f') - n = n - ('a' - 10); - else if ('A' <= n && n <= 'F') - n = n - ('A' - 10); - else - break; - v = (v << 4) | n; - n = ao_usb_getchar(); - } - return v; -} - -void -ao_block_erase(void) -{ - uint32_t addr = ao_get_hex32(); - uint32_t *p = (uint32_t *) addr; - - ao_flash_erase_page(p); -} - -void -ao_block_write(void) -{ - uint32_t addr = ao_get_hex32(); - uint32_t *p = (uint32_t *) addr; - union { - uint8_t data8[256]; - uint32_t data32[64]; - } u; - uint16_t i; - - if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) { - ao_put_string("Invalid address\n"); - return; - } - for (i = 0; i < 256; i++) - u.data8[i] = ao_usb_getchar(); - ao_flash_page(p, u.data32); -} - -void -ao_block_read(void) -{ - uint32_t addr = ao_get_hex32(); - uint8_t *p = (uint8_t *) addr; - uint16_t i; - uint8_t c; - - for (i = 0; i < 256; i++) { - c = *p++; - ao_usb_putchar(c); - } -} - -static void -ao_show_version(void) -{ - ao_put_string("altos-loader"); - ao_put_string("\nmanufacturer "); ao_put_string(ao_manufacturer); - ao_put_string("\nproduct "); ao_put_string(ao_product); - ao_put_string("\nsoftware-version "); ao_put_string(ao_version); - ao_put_string("\n"); -} - -static void -ao_flash_task(void) { - for (;;) { - ao_usb_flush(); - switch (ao_usb_getchar()) { - case 'v': ao_show_version(); break; - case 'a': ao_application(); break; - case 'X': ao_block_erase(); break; - case 'W': ao_block_write(); break; - case 'R': ao_block_read(); break; - } - } -} - - -int -main(void) -{ - ao_clock_init(); - -// ao_timer_init(); -// ao_dma_init(); -// ao_exti_init(); - ao_usb_init(); - - ao_flash_task(); - return 0; -} diff --git a/src/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs new file mode 100644 index 00000000..016bb7e7 --- /dev/null +++ b/src/stm/Makefile-flash.defs @@ -0,0 +1,92 @@ +vpath % $(TOPDIR)/stm:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/core:$(TOPDIR)/util:$(TOPDIR) +vpath ao-make-product.5c $(TOPDIR)/util + +.SUFFIXES: .elf .ihx + +.elf.ihx: + objcopy -O ihex $*.elf $@ + +CC=arm-none-eabi-gcc +SAT=/opt/cortex +SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a +SAT_CFLAGS=-I$(SAT)/include + +ifndef VERSION +include $(TOPDIR)/Version +endif + +AO_CFLAGS=-I. -I$(TOPDIR)/stm -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) +STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS) + +LDFLAGS=-L$(TOPDIR)/stm -Wl,-Taltos-loader.ld + +NICKLE=nickle + +V=0 +# The user has explicitly enabled quiet compilation. +ifeq ($(V),0) +quiet = @printf " $1 $2 $@\n"; $($1) +endif +# Otherwise, print the full command line. +quiet ?= $($1) + +.c.o: + $(call quiet,CC) -c $(CFLAGS) -o $@ $< + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_flash_pins.h \ + ao_flash_stm_pins.h \ + ao_flash_task.h \ + ao_pins.h \ + ao_product.h \ + Makefile + +# +# Common AltOS sources +# +SRC = \ + ao_interrupt.c \ + ao_romconfig.c \ + ao_boot_chain.c \ + ao_boot_pin.c \ + ao_product.c \ + ao_notask.c \ + ao_timer.c \ + ao_usb_stm.c \ + ao_flash_stm.c \ + ao_flash_task.c \ + ao_flash_loader_stm.c + +OBJ=$(SRC:.c=.o) + +PRODUCT=AltosFlash-$(VERSION) +PRODUCT_DEF=-DALTOS_FLASH +IDPRODUCT=0x000a + +CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -g -Os + +PROGNAME=altos-flash +PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf + +$(PROG): Makefile $(OBJ) altos-loader.ld + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc + +ao_product.h: ao-make-product.5c $(TOPDIR)/Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +$(OBJ): $(INC) + +all: $(PROG) + +distclean: clean + +clean: + rm -f *.o $(PROG) + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/stm/altos-loader.ld b/src/stm/altos-loader.ld index 5e10e5ba..2be964f2 100644 --- a/src/stm/altos-loader.ld +++ b/src/stm/altos-loader.ld @@ -32,19 +32,16 @@ SECTIONS { .text : { __text_start__ = .; *(.interrupt) /* Interrupt vectors */ - *(.romconfig*) - *(.text) /* Executable code */ - . = ALIGN(4); - *(.rodata*) /* Constants */ - . = ALIGN(4); - } > rom - .ARM.exidx : { - . = ALIGN(4); + . = ORIGIN(rom) + 0x100; + + ao_romconfig.o(.romconfig*) + ao_product.o(.romconfig*) + *(.text) /* Executable code */ *(.ARM.exidx* .gnu.linkonce.armexidx.*) - . = ALIGN(4); + *(.rodata*) /* Constants */ + __text_end__ = .; } > rom - __text_end__ = .; /* Boot data which must live at the start of ram so that * the application and bootloader share the same addresses. @@ -53,12 +50,20 @@ SECTIONS { .boot (NOLOAD) : { __boot_start__ = .; *(.boot) - . = ALIGN(4); __boot_end__ = .; } >ram - /* Functions placed in RAM (required for flashing) */ - .textram : { + /* Functions placed in RAM (required for flashing) + * + * Align to 8 bytes as that's what the ARM likes text + * segment alignments to be, and if we don't, then + * we end up with a mismatch between the location in + * ROM and the desired location in RAM. I don't + * entirely understand this, but at least this appears + * to work... + */ + + .textram BLOCK(8): { __data_start__ = .; __text_ram_start__ = .; *(.text.ram) diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index 757b5251..adc288c3 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -88,6 +88,10 @@ extern const uint32_t ao_radio_cal; * For now, we're running at a weird frequency */ +#ifndef AO_HSE +#error High speed frequency undefined +#endif + #if AO_HSE #define AO_PLLSRC AO_HSE #else diff --git a/src/stm/ao_flash.h b/src/stm/ao_flash.h new file mode 100644 index 00000000..09ca5ac1 --- /dev/null +++ b/src/stm/ao_flash.h @@ -0,0 +1,27 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_FLASH_STM_H_ +#define _AO_FLASH_STM_H_ + +void +ao_flash_erase_page(uint32_t *page); + +void +ao_flash_page(uint32_t *page, uint32_t *src); + +#endif /* _AO_FLASH_STM_H_ */ diff --git a/src/stm/ao_flash_loader_stm.c b/src/stm/ao_flash_loader_stm.c new file mode 100644 index 00000000..2ab548cf --- /dev/null +++ b/src/stm/ao_flash_loader_stm.c @@ -0,0 +1,32 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include +#include +#include + +int +main(void) +{ + ao_clock_init(); + + ao_usb_init(); + + ao_flash_task(); + return 0; +} diff --git a/src/stm/ao_flash_stm.c b/src/stm/ao_flash_stm.c index b4d47024..d7a85582 100644 --- a/src/stm/ao_flash_stm.c +++ b/src/stm/ao_flash_stm.c @@ -16,7 +16,7 @@ */ #include -#include +#include static uint8_t ao_flash_pecr_is_locked(void) diff --git a/src/stm/ao_flash_stm.h b/src/stm/ao_flash_stm.h deleted file mode 100644 index 09ca5ac1..00000000 --- a/src/stm/ao_flash_stm.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright © 2013 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_FLASH_STM_H_ -#define _AO_FLASH_STM_H_ - -void -ao_flash_erase_page(uint32_t *page); - -void -ao_flash_page(uint32_t *page, uint32_t *src); - -#endif /* _AO_FLASH_STM_H_ */ diff --git a/src/stm/ao_flash_stm_pins.h b/src/stm/ao_flash_stm_pins.h new file mode 100644 index 00000000..d157a226 --- /dev/null +++ b/src/stm/ao_flash_stm_pins.h @@ -0,0 +1,43 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_FLASH_STM_PINS_H_ +#define _AO_FLASH_STM_PINS_H_ + +#include + +/* PLLVCO = 96MHz (so that USB will work) */ +#define AO_PLLMUL 12 +#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12) + +/* SYSCLK = 32MHz */ +#define AO_PLLDIV 3 +#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3) + +/* HCLK = 32MHZ (CPU clock) */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* Run APB1 at HCLK/1 */ +#define AO_APB1_PRESCALER 1 +#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_1 + +/* Run APB2 at HCLK/1 */ +#define AO_APB2_PRESCALER 1 +#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_1 + +#endif /* _AO_FLASH_STM_PINS_H_ */ diff --git a/src/telegps-v0.1/flash-loader/Makefile b/src/telegps-v0.1/flash-loader/Makefile new file mode 100644 index 00000000..efc98d14 --- /dev/null +++ b/src/telegps-v0.1/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=telegps-v0.1 +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/telegps-v0.1/flash-loader/ao_pins.h b/src/telegps-v0.1/flash-loader/ao_pins.h new file mode 100644 index 00000000..564e84de --- /dev/null +++ b/src/telegps-v0.1/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Telemetry TX pin PB6 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiob +#define AO_BOOT_APPLICATION_PIN 6 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#endif /* _AO_PINS_H_ */ diff --git a/src/telemega-v0.1/flash-loader/Makefile b/src/telemega-v0.1/flash-loader/Makefile new file mode 100644 index 00000000..7aa8549f --- /dev/null +++ b/src/telemega-v0.1/flash-loader/Makefile @@ -0,0 +1,7 @@ +# +# AltOS flash loader build +# + +TOPDIR=../.. +HARDWARE=telemega-v0.1 +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/telemega-v0.1/flash-loader/ao_pins.h b/src/telemega-v0.1/flash-loader/ao_pins.h new file mode 100644 index 00000000..1af92f13 --- /dev/null +++ b/src/telemega-v0.1/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Companion port cs_companion0 PD0 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiod +#define AO_BOOT_APPLICATION_PIN 0 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#endif /* _AO_PINS_H_ */ diff --git a/src/telemega-v0.3/flash-loader/Makefile b/src/telemega-v0.3/flash-loader/Makefile new file mode 100644 index 00000000..8fda18cd --- /dev/null +++ b/src/telemega-v0.3/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=telemega-v0.3 +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/telemega-v0.3/flash-loader/ao_pins.h b/src/telemega-v0.3/flash-loader/ao_pins.h new file mode 100644 index 00000000..1af92f13 --- /dev/null +++ b/src/telemega-v0.3/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Companion port cs_companion0 PD0 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiod +#define AO_BOOT_APPLICATION_PIN 0 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3