diff --git a/arch/arm/src/sam34/chip/sam3u_pio.h b/arch/arm/src/sam34/chip/sam3u_pio.h index db64ff63f6e..0ce331d18de 100644 --- a/arch/arm/src/sam34/chip/sam3u_pio.h +++ b/arch/arm/src/sam34/chip/sam3u_pio.h @@ -212,7 +212,7 @@ #define SAM_PIOA_WPSR (SAM_PIOA_BASE+SAM_PIO_WPSR_OFFSET) #define SAM_PIOB_PER (SAM_PIOB_BASE+SAM_PIO_PER_OFFSET) -#define SAM_PIOB_PDR_ (SAM_PIOB_BASE+SAM_PIO_PDR_OFFSET) +#define SAM_PIOB_PDR (SAM_PIOB_BASE+SAM_PIO_PDR_OFFSET) #define SAM_PIOB_PSR (SAM_PIOB_BASE+SAM_PIO_PSR_OFFSET) #define SAM_PIOB_OER (SAM_PIOB_BASE+SAM_PIO_OER_OFFSET) #define SAM_PIOB_ODR (SAM_PIOB_BASE+SAM_PIO_ODR_OFFSET) @@ -256,7 +256,7 @@ #define SAM_PIOB_WPSR (SAM_PIOB_BASE+SAM_PIO_WPSR_OFFSET) #define SAM_PIOC_PER (SAM_PIOC_BASE+SAM_PIO_PER_OFFSET) -#define SAM_PIOC_PDR_ (SAM_PIOC_BASE+SAM_PIO_PDR_OFFSET) +#define SAM_PIOC_PDR (SAM_PIOC_BASE+SAM_PIO_PDR_OFFSET) #define SAM_PIOC_PSR (SAM_PIOC_BASE+SAM_PIO_PSR_OFFSET) #define SAM_PIOC_OER (SAM_PIOC_BASE+SAM_PIO_OER_OFFSET) #define SAM_PIOC_ODR (SAM_PIOC_BASE+SAM_PIO_ODR_OFFSET) diff --git a/arch/arm/src/sam34/chip/sam3x_memorymap.h b/arch/arm/src/sam34/chip/sam3x_memorymap.h index a477dfe3d32..47ce5d83105 100644 --- a/arch/arm/src/sam34/chip/sam3x_memorymap.h +++ b/arch/arm/src/sam34/chip/sam3x_memorymap.h @@ -58,17 +58,19 @@ /* Code memory region */ #define SAM_BOOTMEMORY_BASE 0x00000000 /* 0x00000000-0x003fffff: Boot Memory */ -#define SAM_INTFLASH0_BASE 0x00400000 /* 0x00400000-0x000fffff: Internal FLASH 0 */ -#define SAM_INTFLASH1_BASE (0x00400000 + SAM34_FLASH_SIZE/2) -#define SAM_INTROM_BASE 0x00800000 /* 0x00180000-0x00bfffff: Internal ROM */ - /* 0x00c00000-0x1fffffff: Reserved */ +#define SAM_INTFLASH0_BASE 0x00080000 /* 0x00080000-0x000fffff: Internal FLASH 0 */ +#define SAM_INTFLASH1_BASE (0x00080000 + SAM34_FLASH_SIZE/2) +#define SAM_INTROM_BASE 0x00100000 /* 0x00100000-0x001fffff: Internal ROM */ + /* 0x00200000-0x1fffffff: Reserved */ /* Internal SRAM memory region */ #define SAM_INTSRAM0_BASE 0x20000000 /* 0x20000000-0x2007ffff: Internal SRAM 0 */ #define SAM_INTSRAM1_BASE 0x20080000 /* 0x20080000-0x200fffff: Internal SRAM 0 */ #define SAM_NFCSRAM_BASE 0x20100000 /* 0x20100000-0x2017ffff: NAND FLASH controller (SRAM) */ #define SAM_UOTGHSRAM_BASE 0x20180000 /* 0x20100000-0x201fffff: UOTGHS controller (DMA) */ - /* 0x20200000-0x3fffffff: Undefined */ + /* 0x20200000-0x201fffff: Undefined */ +#define SAM_BBSRAM_BASE 0x22000000 /* 0x22000000-0x23ffffff: 32Mb bit-band alias */ + /* 0x24000000-0x3fffffff: Undefined */ /* Peripherals address region */ #define SAM_HSMCI_BASE 0x40000000 /* 0x40000000-0x400003ff: High Speed Multimedia Card Interface */ @@ -109,7 +111,10 @@ #define SAM_DACC_BASE 0x400c8000 /* 0x400c8000-0x400cffff: Digital To Analog Converter */ /* 0x400d0000-0x400dffff: Reserved */ #define SAM_SYSCTRLR_BASE 0x400e0000 /* 0x400e0000-0x4007ffff: System Controller */ - /* 0x40080000-0x400fffff: Reserved */ + /* 0x40080000-0x40ffffff: Reserved */ + /* 0x41000000-0x41ffffff: Undefined */ +#define SAM_BBPERIPH_BASE 0x42000000 /* 0x42000000-0x43ffffff: 32Mb bit-band alias */ + /* 0x44000000-0x5fffffff: Undefined */ /* System Controller Register Blocks: 0x400e0000-0x4007ffff */ #define SAM_SMC_BASE 0x400e0000 /* 0x400e0000-0x400e01ff: Static Memory Controller */ diff --git a/arch/arm/src/sam34/sam3u_gpio.c b/arch/arm/src/sam34/sam3u_gpio.c index 90d5d2157b3..a1ce7953fca 100644 --- a/arch/arm/src/sam34/sam3u_gpio.c +++ b/arch/arm/src/sam34/sam3u_gpio.c @@ -252,7 +252,7 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, putreg32(pin, base + SAM_PIO_CODR_OFFSET); } - /* Configure the pin as an input and enable the GPIO function */ + /* Configure the pin as an output and enable the GPIO function */ putreg32(pin, base + SAM_PIO_OER_OFFSET); putreg32(pin, base + SAM_PIO_PER_OFFSET); diff --git a/configs/arduino-due/README.txt b/configs/arduino-due/README.txt index e58d5507d7e..03cf58b43bc 100644 --- a/configs/arduino-due/README.txt +++ b/configs/arduino-due/README.txt @@ -411,113 +411,138 @@ Loading Code Uploading NuttX to the Due Using Bossa: --------------------------------------- - Generic BOSSA installation files are avaialable here: - http://sourceforge.net/projects/b-o-s-s-a/?source=dlp + Where do you get it? + Generic BOSSA installation files are avaialable here: + http://sourceforge.net/projects/b-o-s-s-a/?source=dlp - However, DUE uses a patched version of BOSSA available as source code here: - https://github.com/shumatech/BOSSA/tree/arduino + However, DUE uses a patched version of BOSSA available as source code here: + https://github.com/shumatech/BOSSA/tree/arduino - But, fortunately, since you already installed Arduino, you already have - BOSSA installed here. In my installation, it is here: + But, fortunately, since you already installed Arduino, you already have + BOSSA installed. In my installation, it is here: - C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools\bossac.exe + C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools\bossac.exe - Where is some sample output from a Windows CMD.exe shell. NOTE that my - Arduino programming port shows up as COM26. It may be different on your - system. + General Procedure + ----------------- - To enter boot mode, set the baud to 1200 and send anything to the - programming port: + 1) Erase the FLASH and put the Due in bootloader mode + 2) Write the file to FLASH + 3) Configure to boot from FLASH + 4) Reset the DUE - C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools>mode com26:1200,n,8,1 + Erase FLASH and Put the Due in Bootloader Mode + ---------------------------------------------- + This is accomplished by simply configuring the programming port in 1200 + baud and sending something on the programming port. Here is some sample + output from a Windows CMD.exe shell. NOTE that my Arduino programming + port shows up as COM26. It may be different on yoursystem. - Status for device COM26: - ------------------------ - Baud: 1200 - Parity: None - Data Bits: 8 - Stop Bits: 1 - Timeout: ON - XON/XOFF: OFF - CTS handshaking: OFF - DSR handshaking: OFF - DSR sensitivity: OFF - DTR circuit: ON - RTS circuit: ON + To enter boot mode, set the baud to 1200 and send anything to the + programming port: - C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools>bossac.exe --port=COM26 -U false -i - Device : ATSAM3X8 - Chip ID : 285e0a60 - Version : v1.1 Dec 15 2010 19:25:04 - Address : 524288 - Pages : 2048 - Page Size : 256 bytes - Total Size : 512KB - Planes : 2 - Lock Regions : 32 - Locked : none - Security : false - Boot Flash : false + C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools>mode com26:1200,n,8,1 - In a Cygwin BaSH shell: + Status for device COM26: + ------------------------ + Baud: 1200 + Parity: None + Data Bits: 8 + Stop Bits: 1 + Timeout: ON + XON/XOFF: OFF + CTS handshaking: OFF + DSR handshaking: OFF + DSR sensitivity: OFF + DTR circuit: ON + RTS circuit: ON - export PATH="/cygdrive/c/Program Files (x86)/Arduino/arduino-1.5.2/hardware/tools":$PATH + C:\Program Files (x86)\Arduino\arduino-1.5.2\hardware\tools>bossac.exe --port=COM26 -U false -i + Device : ATSAM3X8 + Chip ID : 285e0a60 + Version : v1.1 Dec 15 2010 19:25:04 + Address : 524288 + Pages : 2048 + Page Size : 256 bytes + Total Size : 512KB + Planes : 2 + Lock Regions : 32 + Locked : none + Security : false + Boot Flash : false - Erasing, writing, and verifying FLASH with bossac: + Writing FLASH and Setting FLASH Boot Mode + ----------------------------------------- + In a Cygwin BaSH shell: - $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R - No device found on COM26 + export PATH="/cygdrive/c/Program Files (x86)/Arduino/arduino-1.5.2/hardware/tools":$PATH - This error means that there is code running on the Due already so the - bootloader cannot connect. Pressing reset and trying again + Erasing, writing, and verifying FLASH with bossac: - $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R - No device found on COM26 + $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R + Erase flash + Write 86588 bytes to flash + [==============================] 100% (339/339 pages) + Verify 86588 bytes of flash + [==============================] 100% (339/339 pages) + Verify successful + Set boot flash true + CPU reset. - Sill No connection because Duo does not jump to bootloader after reset.\ - Press ERASE button and try again + Some things that can go wrong: - $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R - Erase flash - Write 86588 bytes to flash - [==============================] 100% (339/339 pages) - Verify 86588 bytes of flash - [==============================] 100% (339/339 pages) - Verify successful - Set boot flash true - CPU reset. + $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R + No device found on COM26 + + This error means that there is code running on the Due already so the + bootloader cannot connect. Pressing reset and trying again + + $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R + No device found on COM26 + + Sill No connection because Duo does not jump to bootloader after reset. + Press ERASE button and try again + + $ bossac.exe --port=COM26 -U false -e -w -v -b nuttx.bin -R + Erase flash + Write 86588 bytes to flash + [==============================] 100% (339/339 pages) + Verify 86588 bytes of flash + [==============================] 100% (339/339 pages) + Verify successful + Set boot flash true + CPU reset. Other useful bossac things operations. + ------------------------------------- + a) Write code to FLASH don't change boot mode and don't reset. This lets + you examine the FLASH contents that you just loaded while the bootloader + is still active. - a) Write code to FLASH don't change boot mode and don't reset. This lets - you examine the FLASH contents that you just loaded while the bootloader - is still active. + $ bossac.exe --port=COM26 -U false -e -w -v --boot=0 nuttx.bin + Write 64628 bytes to flash + [==============================] 100% (253/253 pages) + Verify 64628 bytes of flash + [==============================] 100% (253/253 pages) + Verify successful - $ bossac.exe --port=COM26 -U false -e -w -v nuttx.bin - Write 64628 bytes to flash - [==============================] 100% (253/253 pages) - Verify 64628 bytes of flash - [==============================] 100% (253/253 pages) - Verify successful - Set boot flash true + b) Verify the FLASH contents (the bootloader must be running) - Verify the FLASH contents (the bootloader must be running) + $ bossac.exe --port=COM26 -U false -v nuttx.bin + Verify 64628 bytes of flash + [==============================] 100% (253/253 pages) + Verify successful - $ bossac.exe --port=COM26 -U false -v nuttx.bin - Verify 64628 bytes of flash - [==============================] 100% (253/253 pages) - Verify successful + c) Read from FLASH to a file (the bootloader must be running): - Read from FLASH to a file (the bootloader must be running): + $ bossac.exe --port=COM26 -U false --read=4096 nuttx.dump + Read 4096 bytes from flash + [==============================] 100% (16/16 pages) - $ bossac.exe --port=COM26 -U false --read=4096 nuttx.dump - Read 4096 bytes from flash - [==============================] 100% (16/16 pages) + d) Change to boot from FLASH - Change to boot from FLASH - - $ bossac.exe --port=COM26 -U false --boot=1 - Set boot flash true + $ bossac.exe --port=COM26 -U false --boot=1 + Set boot flash true Uploading NuttX to the Due Using JTAG: ------------------------------------- diff --git a/configs/arduino-due/include/board.h b/configs/arduino-due/include/board.h index 3bff2338ed7..5161cbe6001 100644 --- a/configs/arduino-due/include/board.h +++ b/configs/arduino-due/include/board.h @@ -44,6 +44,7 @@ #ifndef __ASSEMBLY__ # include +# include # ifdef CONFIG_GPIO_IRQ # include # endif @@ -127,16 +128,17 @@ /* FLASH wait states * - * FWS Max frequency + * FWS MAX FREQUENCY * 1.62V 1.8V * --- ----- ------ - * 0 24MHz 27MHz - * 1 40MHz 47MHz - * 2 72MHz 84MHz - * 3 84MHz 96MHz + * 0 17MHz 19MHz + * 1 45MHz 50MHz + * 2 58MHz 64MHz + * 3 70MHz 80MHz + * 4 78MHz 90MHz */ -#define BOARD_FWS 2 +#define BOARD_FWS 4 /* LED definitions ******************************************************************/ /* There are two user-controllable LEDs on board the Arduino Due board: diff --git a/configs/arduino-due/scripts/ld.script b/configs/arduino-due/scripts/ld.script index 27c96360db3..66ba17e8d97 100755 --- a/configs/arduino-due/scripts/ld.script +++ b/configs/arduino-due/scripts/ld.script @@ -33,13 +33,13 @@ * ****************************************************************************/ -/* The ATSAM3X8E has 512KB of FLASH beginning at address 0x0040:0000 and +/* The ATSAM3X8E has 512KB of FLASH beginning at address 0x0008:0000 and * up to 100KB SRAM in three memory regions. */ MEMORY { - flash (rx) : ORIGIN = 0x00400000, LENGTH = 1024K + flash (rx) : ORIGIN = 0x00080000, LENGTH = 1024K sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 64K sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 32K nfcram (rwx) : ORIGIN = 0x20100000, LENGTH = 4K