From 221783226c8f457e094a04c5f4da9e2e3e7e8b42 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Tue, 5 Feb 2008 23:10:45 -0700 Subject: [PATCH] snapshot of my first "working" version from turn-on of Altus Metrum v0.1 --- Makefile | 15 +++++++++++++-- Windows/usbser.sys | Bin 22766 -> 22767 bytes adc/adc.c | 1 + adc/adc.h | 1 + i2c/eeprom.c | 6 ++++++ i2c/eeprom.h | 6 +++++- i2c/i2cInt.c | 8 ++++++++ init.gdb | 19 +++++++++++++++++++ main.c | 10 ++++++++++ oocd_flash_lpc2148.script | 26 ++++++++++++++++++++++++++ openocd-debug.cfg | 29 +++++++++++++++++++++++++++++ openocd-flash.cfg | 29 +++++++++++++++++++++++++++++ sysdefs.h | 2 +- 13 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 init.gdb create mode 100644 oocd_flash_lpc2148.script create mode 100644 openocd-debug.cfg create mode 100644 openocd-flash.cfg diff --git a/Makefile b/Makefile index 28b15e1..11bd29d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.SILENT: +#.SILENT: # # -D CFG_CONSOLE_USB for console on USB @@ -17,7 +17,7 @@ export OBJCOPY=arm-elf-objcopy export OBJDUMP=arm-elf-objdump export CRT0=boot.s export WARNINGS=-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused -export CFLAGS=$(WARNINGS) -D RUN_MODE=RUN_FROM_ROM -D GCC_ARM7 $(INCLUDES) $(BASEINCLUDE) -mcpu=arm7tdmi -T$(LDSCRIPT) -g -O3 -fomit-frame-pointer $(LPC2148DEMO_OPTS) +export CFLAGS=$(WARNINGS) -D RUN_MODE=RUN_FROM_ROM -D GCC_ARM7 $(INCLUDES) $(BASEINCLUDE) -mcpu=arm7tdmi -T$(LDSCRIPT) -g -O3 -fomit-frame-pointer $(LPC2148DEMO_OPTS) -DFC1025 -DBDALE export LDSCRIPT=lpc2148-rom.ld export LINKER_FLAGS=$(COMMON)/common.a -Xlinker -olpc2148.elf -Xlinker -M -Xlinker -Map=lpc2148.map export ROOT=$(shell pwd) @@ -38,11 +38,22 @@ all : @for i in $(SUBDIRS); do \ (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) all); done make lpc2148.hex + make lpc2148.bin + +program: lpc2148.bin + sudo openocd -f ./openocd-flash.cfg + +debug: lpc2148.bin + sudo openocd -f ./openocd-debug.cfg lpc2148.hex : .depend Makefile lpc2148.elf $(OBJCOPY) lpc2148.elf -O ihex lpc2148.hex @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes" +lpc2148.bin : .depend Makefile lpc2148.elf + $(OBJCOPY) lpc2148.elf -O binary lpc2148.bin + @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes" + lpc2148.elf : .depend Makefile $(ARM_OBJ) $(COMMON)/common.a $(CRT0) $(LDSCRIPT) $(CC) $(CFLAGS) $(ARM_OBJ) -nostartfiles $(CRT0) $(LINKER_FLAGS) $(OBJDUMP) -d -S lpc2148.elf >lpc2148.lst diff --git a/Windows/usbser.sys b/Windows/usbser.sys index b390c36e335e50efc4dafeeb399886e88cf7b449..065c75f81a4bb71ba1f0484ded0c011b41a93110 100755 GIT binary patch delta 14 VcmaF2k@5XT#tEg2yc= 65536) +#ifdef FC1025 + deviceAddress |= 0x08; + else + deviceAddress &= ~0x08; +#else deviceAddress |= 0x02; else deviceAddress &= ~0x02; +#endif return r; } diff --git a/i2c/eeprom.h b/i2c/eeprom.h index bfd1412..e10ba8f 100644 --- a/i2c/eeprom.h +++ b/i2c/eeprom.h @@ -6,7 +6,11 @@ // #define EEPROM_ADDRESS (0xa0) #define EEPROM_SIZE (131072) -#define EEPROM_PAGESIZE (256) +#ifdef FC1025 +# define EEPROM_PAGESIZE (128) +#else +# define EEPROM_PAGESIZE (256) +#endif // // diff --git a/i2c/i2cInt.c b/i2c/i2cInt.c index 80f0bdf..24cb26d 100644 --- a/i2c/i2cInt.c +++ b/i2c/i2cInt.c @@ -185,8 +185,16 @@ void i2cInit (void) I2C0_CONCLR = I2C_CONCLR_MASK; I2C0_CONSET = I2C_CONSET_I2EN; +#ifdef FC1025 + // the Microchip 24FC1025 can handle a 1 Mhz clock + // PCLK / (i2c_clock * 2), with 48 Mhz PCLK that's 24... + // for AltusMetrum, 14.7456 Mhz xtal, it's 29.4912, use 30. + I2C0_SCLL = 30; + I2C0_SCLH = 30; +#else I2C0_SCLL = 240; I2C0_SCLH = 240; +#endif // // Initialize the interrupt vector diff --git a/init.gdb b/init.gdb new file mode 100644 index 0000000..2f3d1b9 --- /dev/null +++ b/init.gdb @@ -0,0 +1,19 @@ +# configure gdb to use openocd to talk to the LPC2148 board via Olimex USB JTAG + +#target remote localhost:3333 +#monitor arm7_9 sw_bkpts enable +#monitor poll + +target remote localhost:3333 +monitor reset +monitor sleep 500 +monitor soft_reset_halt +#monitor mww 0xFFFFFF00 0x01 +#monitor reg pc 0x00000000 +monitor poll +monitor wait_halt +monitor ARM7_9 force_hw_bkpts enable +symbol-file lpc2148.elf +thbreak main +#load +continue diff --git a/main.c b/main.c index 7f668d0..7a7fe8c 100644 --- a/main.c +++ b/main.c @@ -58,29 +58,39 @@ xTaskHandle taskHandles [TASKHANDLE_LAST]; int main (void) { cpuSetupHardware (); +//#ifndef BDALE uartInit (0, BAUD_UART0, 64); uartInit (1, BAUD_UART1, 64); +//#endif #ifndef CFG_USB_MSC usbserInit (); #else usbmassInit (); #endif +//#ifndef BDALE rtcInit (); adcInit (); dacInit (); +//#endif i2cInit (); +//#ifndef BDALE eintsInit (); fiqInit (); iapInit (); +//#endif memset (taskHandles, 0, sizeof (taskHandles)); xTaskCreate (vSensorsTask, (const signed portCHAR * const) "Sensors", 512, NULL, (configMAX_PRIORITIES - 2), &taskHandles [TASKHANDLE_SENSORS]); +//#ifndef BDALE #ifndef CFG_CONSOLE_UART1 xTaskCreate (vGPSTask, (const signed portCHAR * const) "GPS", 768, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_GPS]); #endif +//#endif xTaskCreate (vMonitorTask, (const signed portCHAR * const) "Monitor", 1024, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_MONITOR]); +//#ifndef BDALE xTaskCreate (vLEDFlashTask, (const signed portCHAR * const) "LEDx", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_LED]); +//#endif vTaskStartScheduler (); return 0; diff --git a/oocd_flash_lpc2148.script b/oocd_flash_lpc2148.script new file mode 100644 index 0000000..8ec897b --- /dev/null +++ b/oocd_flash_lpc2148.script @@ -0,0 +1,26 @@ +# +# The following commands will be executed on +# reset (because of run_and_init in the config-file) +# - wait for target halt +# - erase memory +# - flash content of file main.bin into target-memory +# - shutdown openocd +# +# created by Martin Thomas +# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects +# based on information from Dominic Rath +# +arm7_9 dcc_downloads enable +wait_halt +sleep 10 +poll +flash probe 0 +# erase first bank only: +flash erase 0 0 26 +flash write 0 lpc2148.bin 0x0 +#flash write 0 scripts/lpc2148_freertos.bin 0x0 +#flash write 0 scripts/main.bin 0x0 +reset run +sleep 10 +shutdown + diff --git a/openocd-debug.cfg b/openocd-debug.cfg new file mode 100644 index 0000000..1fafcc9 --- /dev/null +++ b/openocd-debug.cfg @@ -0,0 +1,29 @@ +#daemon configuration +telnet_port 4444 +gdb_port 3333 +#interface +interface ft2232 +ft2232_device_desc "Olimex OpenOCD JTAG" +ft2232_layout "olimex-jtag" +ft2232_vid_pid 0x15BA 0x0003 +jtag_speed 3 +#use combined on interfaces or targets that can't set TRST/SRST separately +#reset_config trst_and_srst separate +reset_config trst_and_srst srst_pulls_trst +#jtag scan chain +#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE) +jtag_device 4 0x1 0xf 0xe +#target configuration +daemon_startup reset +#target +#target arm7tdmi +target arm7tdmi little run_and_init 0 arm7tdmi-s_r4 +run_and_halt_time 0 30 +#target_script 0 reset oocd_flash_lpc2148.script +working_area 0 0x40000000 0x40000 nobackup +#flash configuration +#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 14765 calc_checksum +flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum +arm7_9 swbkpts enable +# For more information about the configuration files, take a look at: +# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger diff --git a/openocd-flash.cfg b/openocd-flash.cfg new file mode 100644 index 0000000..26131e9 --- /dev/null +++ b/openocd-flash.cfg @@ -0,0 +1,29 @@ +#daemon configuration +telnet_port 4444 +gdb_port 3333 +#interface +interface ft2232 +ft2232_device_desc "Olimex OpenOCD JTAG" +ft2232_layout "olimex-jtag" +ft2232_vid_pid 0x15BA 0x0003 +jtag_speed 3 +#use combined on interfaces or targets that can't set TRST/SRST separately +#reset_config trst_and_srst separate +reset_config trst_and_srst srst_pulls_trst +#jtag scan chain +#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE) +jtag_device 4 0x1 0xf 0xe +#target configuration +daemon_startup reset +#target +#target arm7tdmi +target arm7tdmi little run_and_init 0 arm7tdmi-s_r4 +run_and_halt_time 0 30 +target_script 0 reset oocd_flash_lpc2148.script +working_area 0 0x40000000 0x40000 nobackup +#flash configuration +#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 14765 calc_checksum +flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum +arm7_9 swbkpts enable +# For more information about the configuration files, take a look at: +# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger diff --git a/sysdefs.h b/sysdefs.h index 4d0e749..f55c158 100644 --- a/sysdefs.h +++ b/sysdefs.h @@ -36,7 +36,7 @@ typedef volatile U32 REG32; // Yuck. Don't like this here, but what the heck... // #if !defined CFG_CONSOLE_USB && !defined CFG_CONSOLE_UART0 && !defined CFG_CONSOLE_UART1 -#error "Must define CFG_CONSOLE_USB, CFG_CONSOLE_UART0 or CFG_CONSOLE_UART1 +#error "Must define CFG_CONSOLE_USB, CFG_CONSOLE_UART0 or CFG_CONSOLE_UART1" #endif #if defined CFG_CONSOLE_USB && (defined CFG_CONSOLE_UART0 || defined CFG_CONSOLE_UART1) -- 2.30.2