From 1c6de11f772afae9b4155f8a654cadd05125a2de Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 3 Jan 2014 02:41:17 +0200 Subject: Add basic implementation of slice object. So far, only start and stop integer indexes are supported. Step is not supported, as well as objects of arbitrary types. --- stm/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'stm') diff --git a/stm/Makefile b/stm/Makefile index d6c77e2bd..e84e21eae 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -78,6 +78,7 @@ PY_O = \ objnone.o \ objrange.o \ objset.o \ + objslice.o \ objstr.o \ objtuple.o \ objtype.o \ -- cgit v1.2.3 From 2c62e262b2c84b077355d67c6302bd02f6a28552 Mon Sep 17 00:00:00 2001 From: stevie67 Date: Sat, 4 Jan 2014 03:02:32 +0100 Subject: Fix issue #62: Cache loses data Use the storage cache not only for writing but also for reading. This avoids reading stale data and thus data loss. --- stm/storage.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'stm') diff --git a/stm/storage.c b/stm/storage.c index 6878de22e..7342a53ac 100644 --- a/stm/storage.c +++ b/stm/storage.c @@ -49,6 +49,16 @@ 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) + 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 +141,8 @@ 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; + 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; -- cgit v1.2.3 From 2a5e6538b941d1fc9c1c0ef0bb0827b5ed2425d2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 12:34:36 +0000 Subject: stm: Add comments for storage read from cache. --- stm/storage.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stm') diff --git a/stm/storage.c b/stm/storage.c index 7342a53ac..daee4adb5 100644 --- a/stm/storage.c +++ b/stm/storage.c @@ -53,8 +53,10 @@ 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) + 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; } @@ -141,6 +143,7 @@ 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, 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); -- cgit v1.2.3 From eb7bfcb28697f6fb2d4d933bc39233aa15423a20 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 15:57:35 +0000 Subject: Split qstr into pools, and put initial pool in ROM. Qstr's are now split into a linked-list of qstr pools. This has 2 benefits: the first pool can be in ROM (huge benefit, since we no longer use RAM for the core qstrs), and subsequent pools use m_new for the next pool instead of m_renew (thus avoiding a huge single table for all the qstrs). Still would be better to use a hash table, but this scheme takes us part of the way (eventually convert the pools to hash tables). Also fixed bug with import. Also improved the way the module code is referenced (not magic number 1 anymore). --- stm/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'stm') diff --git a/stm/main.c b/stm/main.c index e8db2be2c..b7ae8aacc 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); -- cgit v1.2.3 From 5830fae26f7dfeb7a263ba5e1b024694930c64ff Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 4 Jan 2014 18:55:44 +0200 Subject: Don't error out if build/ directory already exists. --- stm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stm') diff --git a/stm/Makefile b/stm/Makefile index e84e21eae..729913bae 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -162,7 +162,7 @@ $(BUILD)/flash.elf: $(OBJ) arm-none-eabi-size $@ $(BUILD): - mkdir $@ + mkdir -p $@ $(BUILD)/%.o: %.s $(AS) -o $@ $< -- cgit v1.2.3 From 71c5181a8dfa69ba9f5ca322a3aba0660be2e166 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 20:21:15 +0000 Subject: Convert Python types to proper Python type hierarchy. Now much more inline with how CPython does types. --- stm/Makefile | 1 + stm/i2c.c | 1 + stm/led.c | 1 + stm/main.c | 1 + stm/servo.c | 1 + 5 files changed, 5 insertions(+) (limited to 'stm') diff --git a/stm/Makefile b/stm/Makefile index 729913bae..d75c945bf 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -73,6 +73,7 @@ PY_O = \ objfun.o \ objgenerator.o \ objinstance.o \ + objint.o \ objlist.o \ objmodule.o \ objnone.o \ diff --git a/stm/i2c.c b/stm/i2c.c index e00cf4130..3f29f02c0 100644 --- a/stm/i2c.c +++ b/stm/i2c.c @@ -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 diff --git a/stm/led.c b/stm/led.c index 08077641a..9305716be 100644 --- a/stm/led.c +++ b/stm/led.c @@ -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 b7ae8aacc..0ab44ca8d 100644 --- a/stm/main.c +++ b/stm/main.c @@ -746,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 ae421048b..1e31db514 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 -- cgit v1.2.3