#define UTIL_TIMER_APB1 RCC_APB1Periph_TIM7 """) codeOut(""); # ------------------------------------------------------------------------------------- Chip Specifics codeOut("#define RAM_TOTAL ("+str(board.chip['ram'])+"*1024)") codeOut("#define FLASH_TOTAL ("+str(board.chip['flash'])+"*1024)") codeOut(""); if LINUX: codeOut('#define RESIZABLE_JSVARS // Allocate variables in blocks using malloc') else: 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_PAGE_SIZE "+str(flash_page_size)) codeOut("#define FLASH_PAGES "+str(flash_pages)) codeOut("#define BOOTLOADER_SIZE "+str(common.get_bootloader_size())) codeOut(""); codeOut("#define USARTS "+str(board.chip["usart"])) codeOut("#define SPIS "+str(board.chip["spi"])) codeOut("#define I2CS "+str(board.chip["i2c"])) codeOut("#define ADCS "+str(board.chip["adc"])) codeOut("#define DACS "+str(board.chip["dac"])) codeOut(""); codeOut("#define DEFAULT_CONSOLE_DEVICE "+board.info["default_console"]); codeOut(""); codeOut("#define IOBUFFERMASK 31 // (max 255) amount of items in event buffer - events take ~9 bytes each") codeOut("#define TXBUFFERMASK 31 // (max 255)") codeOut(""); codeOutDevice("LED1") codeOutDevice("LED2") codeOutDevice("LED3")
# Check what board py says if ("bootloader" in board.info and board.info["bootloader"] != 0) != (IS_BOOTLOADER or IS_USING_BOOTLOADER): die("Makefile and BOARD.py do not agree over bootloaderiness") # ----------------------------------------------------------------------------------------- linkerFile = open(linkerFilename, 'w') def codeOut(s): linkerFile.write(s + "\n") # ----------------------------------------------------------------------------------------- BOOTLOADER_SIZE = common.get_bootloader_size() RAM_BASE = 0x20000000 FLASH_BASE = 0x08000000 RAM_SIZE = board.chip["ram"] * 1024 FLASH_SIZE = board.chip["flash"] * 1024 # Beware - on some devices (the STM32F4) the memory is divided into two non-continuous blocks if board.chip["family"] == "STM32F4" and RAM_SIZE > 128 * 1204: RAM_SIZE = 128 * 1024 if IS_BOOTLOADER: FLASH_SIZE = BOOTLOADER_SIZE elif IS_USING_BOOTLOADER: FLASH_BASE += BOOTLOADER_SIZE FLASH_SIZE -= BOOTLOADER_SIZE
0.5) #Needs to be a full page, so we're rounding up # F4 has different page sizes in different places total_flash = board.chip["flash"] * 1024 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_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(board) print("Variables = " + str(variables)) print("JsVar size = " + str(var_size)) print("VarCache size = " + str(var_cache_size)) print("Flash page size = " + str(flash_page_size)) print("Flash pages = " + str(flash_saved_code_pages)) print("Total flash = " + str(total_flash)) print("Flash available for code = " + str(flash_available_for_code)) # ----------------------------------------------------------------------------------------- headerFile = open(headerFilename, 'w') def codeOut(s): headerFile.write(s + "\n")
flash_page_size = 4*1024 if board.chip["family"]=="STM32L4": flash_page_size = 128*1024 flash_saved_code_pages = round((flash_needed+flash_page_size-1)/flash_page_size + 0.5) #Needs to be a full page, so we're rounding up # F4 has different page sizes in different places total_flash = board.chip["flash"]*1024 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_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(board) print("Flash page size = "+str(flash_page_size)) print("Flash pages = "+str(flash_saved_code_pages)) print("Total flash = "+str(total_flash)) print("Flash available for code = "+str(flash_available_for_code)) # ----------------------------------------------------------------------------------------- headerFile = open(headerFilename, 'w') def codeOut(s): headerFile.write(s+"\n"); # ----------------------------------------------------------------------------------------- def die(err): print("ERROR: "+err)
print("BOARD "+boardname) print("IS_BOOTLOADER "+str(IS_BOOTLOADER)) print("IS_USING_BOOTLOADER "+str(IS_USING_BOOTLOADER)) # import the board def board = importlib.import_module(boardname) # Check what board py says BOARD_BOOTLOADER = "bootloader" in board.info and board.info["bootloader"]!=0 if BOARD_BOOTLOADER != (IS_BOOTLOADER or IS_USING_BOOTLOADER): die("Makefile ("+str(IS_BOOTLOADER or IS_USING_BOOTLOADER)+") and BOARD.py ("+str(BOARD_BOOTLOADER)+") do not agree over bootloaderiness") # ----------------------------------------------------------------------------------------- linkerFile = open(linkerFilename, 'w') def codeOut(s): linkerFile.write(s+"\n"); # ----------------------------------------------------------------------------------------- BOOTLOADER_SIZE = common.get_bootloader_size(board); RAM_BASE = 0x20000000; FLASH_BASE = 0x08000000; RAM_SIZE = board.chip["ram"]*1024; FLASH_SIZE = board.chip["flash"]*1024; # Beware - on some devices (the STM32F4) the memory is divided into two non-continuous blocks if board.chip["family"]=="STM32F4" and RAM_SIZE > 128*1024: RAM_SIZE = 128*1024 # on L476, the RAM is divided in 2 parts : # 96k at 0x20000000 # 32k at 0x10000000 # Today, the 32k part won't be used. In the future, it can be # used for example for the stack. In this case, need to : # _estack = 0x10008000;
variables = board.info["variables"] var_size = 16 if variables < 255 else 20 var_cache_size = var_size * variables flash_needed = var_cache_size + 4 # for magic number flash_page_size = 1024 # just a geuss 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"] == "STM32F3": flash_page_size = 2 * 1024 if board.chip["family"] == "STM32F4": flash_page_size = 128 * 1024 flash_pages = (flash_needed + flash_page_size - 1) / flash_page_size total_flash = board.chip["flash"] * 1024 flash_available_for_code = total_flash - (flash_pages * flash_page_size) if has_bootloader: flash_available_for_code -= common.get_bootloader_size() print "Variables = " + str(variables) print "JsVar size = " + str(var_size) print "VarCache size = " + str(var_cache_size) print "Flash page size = " + str(flash_page_size) print "Flash pages = " + str(flash_pages) print "Total flash = " + str(total_flash) print "Flash available for code = " + str(flash_available_for_code) # ----------------------------------------------------------------------------------------- headerFile = open(headerFilename, 'w') def codeOut(s): headerFile.write(s + "\n")