diff options
Diffstat (limited to 'stm')
-rw-r--r-- | stm/Makefile | 4 | ||||
-rw-r--r-- | stm/i2c.c | 1 | ||||
-rw-r--r-- | stm/led.c | 1 | ||||
-rw-r--r-- | stm/main.c | 4 | ||||
-rw-r--r-- | stm/servo.c | 1 | ||||
-rw-r--r-- | stm/storage.c | 17 |
6 files changed, 24 insertions, 4 deletions
diff --git a/stm/Makefile b/stm/Makefile index d6c77e2bd7..d75c945bfc 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -73,11 +73,13 @@ PY_O = \ objfun.o \ objgenerator.o \ objinstance.o \ + objint.o \ objlist.o \ objmodule.o \ objnone.o \ objrange.o \ objset.o \ + objslice.o \ objstr.o \ objtuple.o \ objtype.o \ @@ -161,7 +163,7 @@ $(BUILD)/flash.elf: $(OBJ) arm-none-eabi-size $@ $(BUILD): - mkdir $@ + mkdir -p $@ $(BUILD)/%.o: %.s $(AS) -o $@ $< @@ -330,6 +330,7 @@ static const mp_obj_type_t i2c_obj_type = { { &mp_const_type }, "I2C", i2c_obj_print, // print + NULL, // make_new NULL, // call_n NULL, // unary_op NULL, // binary_op @@ -108,6 +108,7 @@ static const mp_obj_type_t led_obj_type = { { &mp_const_type }, "Led", led_obj_print, // print + NULL, // make_new NULL, // call_n NULL, // unary_op NULL, // binary_op diff --git a/stm/main.c b/stm/main.c index e8db2be2ca..0ab44ca8d4 100644 --- a/stm/main.c +++ b/stm/main.c @@ -15,6 +15,7 @@ #include "misc.h" #include "ff.h" #include "mpconfig.h" +#include "mpqstr.h" #include "nlr.h" #include "misc.h" #include "lexer.h" @@ -621,7 +622,7 @@ mp_obj_t pyb_gpio(int n_args, mp_obj_t *args) { } pin_error: - nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_ValueError, "pin %s does not exist", pin_name)); + nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_ValueError, "pin %s does not exist", pin_name)); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_gpio_obj, 1, 2, pyb_gpio); @@ -745,6 +746,7 @@ static const mp_obj_type_t file_obj_type = { { &mp_const_type }, "File", file_obj_print, // print + NULL, // make_new NULL, // call_n NULL, // unary_op NULL, // binary_op diff --git a/stm/servo.c b/stm/servo.c index ae421048b9..1e31db5140 100644 --- a/stm/servo.c +++ b/stm/servo.c @@ -141,6 +141,7 @@ static const mp_obj_type_t servo_obj_type = { { &mp_const_type }, "Servo", servo_obj_print, // print + NULL, // make_new NULL, // call_n NULL, // unary_op NULL, // binary_op diff --git a/stm/storage.c b/stm/storage.c index 6878de22e6..daee4adb5e 100644 --- a/stm/storage.c +++ b/stm/storage.c @@ -49,6 +49,18 @@ static uint8_t *cache_get_addr_for_write(uint32_t flash_addr) { return (uint8_t*)CACHE_MEM_START_ADDR + flash_addr - flash_sector_start; } +static uint8_t *cache_get_addr_for_read(uint32_t flash_addr) { + uint32_t flash_sector_start; + uint32_t flash_sector_size; + uint32_t flash_sector_id = flash_get_sector_info(flash_addr, &flash_sector_start, &flash_sector_size); + if (cache_flash_sector_id == flash_sector_id) { + // in cache, copy from there + return (uint8_t*)CACHE_MEM_START_ADDR + flash_addr - flash_sector_start; + } + // not in cache, copy straight from flash + return (uint8_t*)flash_addr; +} + void storage_init(void) { if (!is_initialised) { cache_flash_sector_id = 0; @@ -131,8 +143,9 @@ bool storage_read_block(uint8_t *dest, uint32_t block) { return true; } else if (FLASH_PART1_START_BLOCK <= block && block < FLASH_PART1_START_BLOCK + FLASH_PART1_NUM_BLOCKS) { - // non-MBR block, just copy straight from flash - uint8_t *src = (uint8_t*)FLASH_MEM_START_ADDR + (block - FLASH_PART1_START_BLOCK) * BLOCK_SIZE; + // non-MBR block, get data from flash memory, possibly via cache + uint32_t flash_addr = FLASH_MEM_START_ADDR + (block - FLASH_PART1_START_BLOCK) * BLOCK_SIZE; + uint8_t *src = cache_get_addr_for_read(flash_addr); memcpy(dest, src, BLOCK_SIZE); return true; |