There is no programming algorithm for DA14531,vendor has provided the tools to develop app based on their platform & hardware.
I don't know others how to develop it without algorithm, it looks like you should upload FW with SmartSnippets and start to run & debug,
that means you'd shift between Keil and SmartSnippets.
I developed a PCBA with DA14531, I hope to programme & debug in Keil only,I need to create a algorithm to load FW to RAM and
execute it.
This is the simple code(FlashPrg.c):
/***********************************************************************/ /* This file is part of the ARM Toolchain package */ /* Copyright KEIL ELEKTRONIK GmbH 2003 - 2010 */ /***********************************************************************/ /* */ /* FlashDev.C: Flash Programming Functions adapted */ /* for DA14531 sysRAM */ /* */ /***********************************************************************/ #include "..\FlashOS.h" // FlashOS Structures typedef volatile unsigned char vu8; typedef volatile unsigned long vu32; typedef volatile unsigned short vu16; #define M8(adr) (*((vu8 *) (adr))) #define M16(adr) (*((vu16 *) (adr))) #define M32(adr) (*((vu32 *) (adr))) unsigned long base_adr; extern struct FlashDevice const FlashDevice; /* * Initialize Flash Programming Functions * Parameter: adr: Device Base Address * clk: Clock Frequency (Hz) * fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify) * Return Value: 0 - OK, 1 - Failed */ int Init (unsigned long adr, unsigned long clk, unsigned long fnc) { base_adr = adr ; // Align to Size Boundary return (0); } /* * De-Initialize Flash Programming Functions * Parameter: fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify) * Return Value: 0 - OK, 1 - Failed */ int UnInit (unsigned long fnc) { return (0); } /* * Erase Sector in Flash Memory * Parameter: adr: Sector Address * Return Value: 0 - OK, 1 - Failed */ int EraseSector (unsigned long adr) { int i; for(i=0;i<1024/sizeof(unsigned long);i++){ M32(adr) = 0; adr += sizeof(unsigned long); } return (0); // Done } /* * Program Page in Flash Memory * Parameter: adr: Page Start Address * sz: Page Size * buf: Page Data * Return Value: 0 - OK, 1 - Failed */ int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) { sz = (sz + 1) & ~3; // Adjust size for Words while (sz) { M32(adr) = *((unsigned long *)buf); // Program Word // Check for Errors if ( M32(adr) != (*((unsigned long *)buf)) ) { return (1); // Failed } // Go to next Word adr += sizeof(unsigned long); buf += sizeof(unsigned long); sz -= sizeof(unsigned long); } return (0); // Done }
FlashDev.c:
/***********************************************************************/ /* This file is part of the ARM Toolchain package */ /* Copyright KEIL ELEKTRONIK GmbH 2003 - 2010 */ /***********************************************************************/ /* */ /* FlashDev.C: Device Description for DA14531 sysRAM */ /* */ /***********************************************************************/ #include "..\FlashOS.h" // FlashOS Structures struct FlashDevice const FlashDevice = { FLASH_DRV_VERS, // Driver Version, do not modify! "DA14531 48K sysRAM", // Device Name (128kB/64kB/32kB) ONCHIP, // Device Type 0x07FC0000, // Device Start Address 0xAC00, // Device Size in Bytes (43K = 48K - 5K, 5K for algorithm) 1024, // Programming Page Size 0, // Reserved, must be 0 0x00, // Initial Content of Erased Memory 100, // Program Page Timeout 100 mSec 500, // Erase Sector Timeout 500 mSec // Specify Size and Address of Sectors 4096, 0x07FC0000, //sysRAM1 16K, Sector Size 4kB (4 Sectors) 4096, 0x07FC4000, //sysRAM2 12K, Sector Size 4kB (3 Sectors) 5120, 0x07FC7000, //sysRAM3 15K, Sector Size 5kB (3 Sectors),reserve 5K for programming algorithm code SECTOR_END };
RAM map of DA14531:
System RAM 48 kB. Contains application code, data for the application, stack, and heap. SysRAM1 (16 kB): 0x07FC0000 to 0x07FC3FFF SysRAM2 (12 kB): 0x07FC4000 to 0x07FC6FFF SysRAM3 (20 kB): 0x07FC7000 to 0x07FCBFFF
My plan to allocate them: 43K(lower part) for FW,5K(higher part) for algorithm.
Size of sysRAM3 is 20K,reserved 5K(highest part) for this algorithm,sowe need to set "RAM for algorithm"(option-debug-settings-Flash download) :
Start: 0x7FCAC00(0x07FCBFFF + 1 - 0x1400) Size:0x1400 (5120/5K)
and "Programming algorithm":
Start: 0x07FC0000 Size: 0xAC00 (43K)
I use blinky(from DA14531 SDK) to test:
Compile & upload,I got this error:
log info:
Flash Load finished at 13:25:59 Load "D:\\DA14531\\Multirole_SDKs\\6.0.20.1338_multirole\\projects\\target_apps\\peripheral_examples\\blinky\\blinky\\Keil_5\\out_DA14531\\Objects\\blinky_531.axf" Erase Failed! Error: Flash Download failed - "Cortex-M0+" Flash Load finished at 13:29:36
I can't find the explanation for "Address not Zero!", it looks like Sector(0) address should not be Zero, but it is not Zero indeed in my case.
And there is a big problem: I don't know the SWD function of PCBA is OK or not, but I checked the Crystal oscillator, there is voltage existed ,though very low.
Any advice is welcome.
Thank you.
Thank you for your answer. I don't know the debugger can load FW to RAM of MCU, the sample from DA14531 has included the ini file,I just tried,loaded indeed.
But,we can still make a algorithm even it is not needed,what the error means?
I will make a algorithm to write to external flash,the way is same,I can learn from testing with RAM.
The reason for the error is simple. The start address of the first Flash sector must be 0. So your device sector table should look like this:
// Specify Size and Address of Sectors 4096, 0x00000000, //sysRAM1 16K, Sector Size 4kB (4 Sectors) 4096, 0x00004000, //sysRAM2 12K, Sector Size 4kB (3 Sectors) 5120, 0x00007000, //sysRAM3 15K, Sector Size 5kB (3 Sectors),reserve 5K for programming algorithm code
Since the RAM does not have sectors, this table can probably be reduced to one line. I would probably specify the size of each sector group (first column) in hex.
So it is impossible for DA14531, it's RAM not starts from 0.
I get it,thank you.
No, every Flash sector table needs to start at address 0. Some lines above, you specify to which address this whole Flash is mapped (see 'Device Start Address'). So you could write a Flash algorithm that loads the application into the RAM but this does not make sense except you want to get experience with writing a Flash algorithm.