mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Tidy up linker script, allow F401 to use 3x16kB pages for storing program data
This commit is contained in:
parent
551748f9d5
commit
dc7ce42703
@ -10,6 +10,7 @@
|
|||||||
Merge fs_kill and file_kill to ensure that files always die before the filesystem
|
Merge fs_kill and file_kill to ensure that files always die before the filesystem
|
||||||
Add `E.unmountSD()` to allow SD cards to be removed once they have been used
|
Add `E.unmountSD()` to allow SD cards to be removed once they have been used
|
||||||
Stop String.split("") adding an empty elementy to the array
|
Stop String.split("") adding an empty elementy to the array
|
||||||
|
Tidy up linker script, allow F401 to use 3x16kB pages for storing program data
|
||||||
|
|
||||||
1v69 : Fix 1v67's regression of digitalPulse when doing lots of pulses
|
1v69 : Fix 1v67's regression of digitalPulse when doing lots of pulses
|
||||||
Add configurable OneWire search command (for finding DS18B20s with alarm set)
|
Add configurable OneWire search command (for finding DS18B20s with alarm set)
|
||||||
|
|||||||
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
import pinutils;
|
import pinutils;
|
||||||
info = {
|
info = {
|
||||||
'name' : "STM32F401 Discovery",
|
'name' : "STM32F401C Discovery",
|
||||||
'link' : [ "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF259098" ],
|
'link' : [ "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF259098" ],
|
||||||
'default_console' : "EV_SERIAL2",
|
'default_console' : "EV_SERIAL2",
|
||||||
'variables' : 2650,
|
'variables' : 3040,
|
||||||
'binary_name' : 'espruino_%v_stm32f401Cdiscovery.bin',
|
'binary_name' : 'espruino_%v_stm32f401cdiscovery.bin',
|
||||||
};
|
};
|
||||||
chip = {
|
chip = {
|
||||||
'part' : "STM32F401VCT6",
|
'part' : "STM32F401VCT6",
|
||||||
@ -33,6 +33,14 @@ chip = {
|
|||||||
'i2c' : 3,
|
'i2c' : 3,
|
||||||
'adc' : 1,
|
'adc' : 1,
|
||||||
'dac' : 0,
|
'dac' : 0,
|
||||||
|
'saved_code' : {
|
||||||
|
'address' : 0x08004000,
|
||||||
|
'page_size' : 16384, # size of pages
|
||||||
|
'page_number' : 1, # number of page we start at (0 based)
|
||||||
|
'pages' : 3, # number of pages we're using
|
||||||
|
'flash_available' : 256 # binary will have a hole in it, so we just want to test against full size
|
||||||
|
},
|
||||||
|
'place_text_section' : 0x08010000, # note flash_available above
|
||||||
};
|
};
|
||||||
# left-right, or top-bottom order
|
# left-right, or top-bottom order
|
||||||
board = {
|
board = {
|
||||||
|
|||||||
@ -126,16 +126,19 @@ SECTIONS
|
|||||||
/* Then code, then constants */
|
/* Then code, then constants */
|
||||||
.text :
|
.text :
|
||||||
{
|
{
|
||||||
|
""")
|
||||||
|
|
||||||
|
if "place_text_section" in board.chip:
|
||||||
|
codeOut(""" /* In the .py file we were told to place text here (to skip out what was before) */
|
||||||
|
. = ALIGN("""+hex(board.chip["place_text_section"]-FLASH_BASE)+"""); /* hacky! really want it absolute */
|
||||||
|
""");
|
||||||
|
|
||||||
|
codeOut("""
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.text*)
|
*(.text*)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
*(.glue_7)
|
|
||||||
*(.glue_7t)
|
|
||||||
|
|
||||||
KEEP (*(.init))
|
|
||||||
KEEP (*(.fini))
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
@ -169,10 +172,8 @@ SECTIONS
|
|||||||
|
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_ebss = .; /* define a global symbol at bss end */
|
_ebss = .; /* define a global symbol at bss end */
|
||||||
__bss_end__ = _ebss;
|
|
||||||
} >RAM
|
} >RAM
|
||||||
|
|
||||||
PROVIDE ( end = _ebss );
|
|
||||||
PROVIDE ( _end = _ebss );
|
PROVIDE ( _end = _ebss );
|
||||||
|
|
||||||
/* Remove stuff we don't want */
|
/* Remove stuff we don't want */
|
||||||
|
|||||||
@ -76,21 +76,35 @@ if not LINUX:
|
|||||||
var_cache_size = var_size*variables
|
var_cache_size = var_size*variables
|
||||||
flash_needed = var_cache_size + 4 # for magic number
|
flash_needed = var_cache_size + 4 # for magic number
|
||||||
flash_page_size = 1024 # just a guess
|
flash_page_size = 1024 # just a guess
|
||||||
|
flash_saved_code_sector = ""
|
||||||
if board.chip["family"]=="STM32F1": flash_page_size = 1024 if "subfamily" in board.chip and board.chip["subfamily"]=="MD" else 2048
|
if board.chip["family"]=="STM32F1": flash_page_size = 1024 if "subfamily" in board.chip and board.chip["subfamily"]=="MD" else 2048
|
||||||
if board.chip["family"]=="STM32F2": flash_page_size = 128*1024
|
if board.chip["family"]=="STM32F2":
|
||||||
|
flash_page_size = 128*1024
|
||||||
|
flash_saved_code_sector = 11
|
||||||
if board.chip["family"]=="STM32F3": flash_page_size = 2*1024
|
if board.chip["family"]=="STM32F3": flash_page_size = 2*1024
|
||||||
if board.chip["family"]=="STM32F4": flash_page_size = 128*1024
|
if board.chip["family"]=="STM32F4":
|
||||||
|
flash_page_size = 128*1024
|
||||||
|
flash_saved_code_sector = 11
|
||||||
# F4 has different page sizes in different places
|
# F4 has different page sizes in different places
|
||||||
flash_pages = (flash_needed+flash_page_size-1)/flash_page_size
|
flash_saved_code_pages = (flash_needed+flash_page_size-1)/flash_page_size
|
||||||
total_flash = board.chip["flash"]*1024
|
total_flash = board.chip["flash"]*1024
|
||||||
flash_available_for_code = total_flash - (flash_pages*flash_page_size)
|
|
||||||
|
if "saved_code" in board.chip:
|
||||||
|
flash_saved_code_start = board.chip["saved_code"]["address"]
|
||||||
|
flash_page_size = board.chip["saved_code"]["page_size"]
|
||||||
|
flash_saved_code_sector = board.chip["saved_code"]["page_number"]
|
||||||
|
flash_saved_code_pages = board.chip["saved_code"]["pages"]
|
||||||
|
flash_available_for_code = board.chip["saved_code"]["flash_available"]*1024
|
||||||
|
else:
|
||||||
|
flash_saved_code_start = "(FLASH_START + FLASH_TOTAL - FLASH_SAVED_CODE_LENGTH)"
|
||||||
|
flash_available_for_code = total_flash - (flash_saved_code_pages*flash_page_size)
|
||||||
if has_bootloader: flash_available_for_code -= common.get_bootloader_size()
|
if has_bootloader: flash_available_for_code -= common.get_bootloader_size()
|
||||||
|
|
||||||
print "Variables = "+str(variables)
|
print "Variables = "+str(variables)
|
||||||
print "JsVar size = "+str(var_size)
|
print "JsVar size = "+str(var_size)
|
||||||
print "VarCache size = "+str(var_cache_size)
|
print "VarCache size = "+str(var_cache_size)
|
||||||
print "Flash page size = "+str(flash_page_size)
|
print "Flash page size = "+str(flash_page_size)
|
||||||
print "Flash pages = "+str(flash_pages)
|
print "Flash pages = "+str(flash_saved_code_pages)
|
||||||
print "Total flash = "+str(total_flash)
|
print "Total flash = "+str(total_flash)
|
||||||
print "Flash available for code = "+str(flash_available_for_code)
|
print "Flash available for code = "+str(flash_available_for_code)
|
||||||
|
|
||||||
@ -222,12 +236,13 @@ else:
|
|||||||
codeOut("#define JSVAR_CACHE_SIZE "+str(variables)+" // Number of JavaScript variables in RAM")
|
codeOut("#define JSVAR_CACHE_SIZE "+str(variables)+" // Number of JavaScript variables in RAM")
|
||||||
codeOut("#define FLASH_AVAILABLE_FOR_CODE "+str(flash_available_for_code))
|
codeOut("#define FLASH_AVAILABLE_FOR_CODE "+str(flash_available_for_code))
|
||||||
codeOut("#define FLASH_PAGE_SIZE "+str(flash_page_size))
|
codeOut("#define FLASH_PAGE_SIZE "+str(flash_page_size))
|
||||||
codeOut("#define FLASH_SAVED_CODE_PAGES "+str(flash_pages))
|
codeOut("#define FLASH_SAVED_CODE_PAGES "+str(flash_saved_code_pages))
|
||||||
codeOut("#define FLASH_START "+hex(0x08000000))
|
codeOut("#define FLASH_START "+hex(0x08000000))
|
||||||
|
if flash_saved_code_sector!="": codeOut("#define FLASH_SAVED_CODE_SECTOR "+str(flash_saved_code_sector))
|
||||||
if has_bootloader: codeOut("#define BOOTLOADER_SIZE "+str(common.get_bootloader_size()))
|
if has_bootloader: codeOut("#define BOOTLOADER_SIZE "+str(common.get_bootloader_size()))
|
||||||
codeOut("")
|
codeOut("")
|
||||||
codeOut("#define FLASH_SAVED_CODE_LENGTH (FLASH_PAGE_SIZE*FLASH_SAVED_CODE_PAGES)")
|
codeOut("#define FLASH_SAVED_CODE_LENGTH (FLASH_PAGE_SIZE*FLASH_SAVED_CODE_PAGES)")
|
||||||
codeOut("#define FLASH_SAVED_CODE_START (FLASH_START + FLASH_TOTAL - FLASH_SAVED_CODE_LENGTH)")
|
codeOut("#define FLASH_SAVED_CODE_START "+str(flash_saved_code_start))
|
||||||
codeOut("#define FLASH_MAGIC_LOCATION (FLASH_SAVED_CODE_START + FLASH_SAVED_CODE_LENGTH - 4)")
|
codeOut("#define FLASH_MAGIC_LOCATION (FLASH_SAVED_CODE_START + FLASH_SAVED_CODE_LENGTH - 4)")
|
||||||
codeOut("#define FLASH_MAGIC 0xDEADBEEF")
|
codeOut("#define FLASH_MAGIC 0xDEADBEEF")
|
||||||
codeOut("");
|
codeOut("");
|
||||||
|
|||||||
@ -2249,7 +2249,10 @@ void jshSaveToFlash() {
|
|||||||
|
|
||||||
jsiConsolePrint("Erasing Flash...");
|
jsiConsolePrint("Erasing Flash...");
|
||||||
#if defined(STM32F2) || defined(STM32F4)
|
#if defined(STM32F2) || defined(STM32F4)
|
||||||
FLASH_EraseSector(FLASH_Sector_11, VoltageRange_3);
|
for (i=0;i<FLASH_SAVED_CODE_PAGES;i++) {
|
||||||
|
FLASH_EraseSector(FLASH_Sector_0 + (FLASH_Sector_1-FLASH_Sector_0)*(FLASH_SAVED_CODE_SECTOR+i), VoltageRange_3); // a FLASH_Sector_## constant
|
||||||
|
jsiConsolePrint(".");
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Erase the FLASH pages */
|
/* Erase the FLASH pages */
|
||||||
for(i=0;i<FLASH_SAVED_CODE_PAGES;i++) {
|
for(i=0;i<FLASH_SAVED_CODE_PAGES;i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user