Skip to content

Commit 5176ffd

Browse files
committed
codal_port: Update to build with latest micropython.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 16fe526 commit 5176ffd

37 files changed

+227
-199
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
src/build
22
src/MICROBIT.hex
33
src/codal_port/build
4-
src/codal_port/libmicropython.a

src/codal.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ index b89e1d0..b53224b 100644
2020
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROJECT_SOURCE_DIR}/../../src/codal_port/filesystem.ld")
2121
+add_library(micropython STATIC IMPORTED)
2222
+set_target_properties(micropython PROPERTIES
23-
+ IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../../src/codal_port/libmicropython.a"
23+
+ IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../../src/codal_port/build/libmicropython.a"
2424
+)
2525
+target_link_libraries("MICROBIT" micropython)

src/codal_port/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ QSTR_DEFS = qstrdefsport.h
1414

1515
# Include py core make definitions.
1616
include $(TOP)/py/py.mk
17+
include $(TOP)/extmod/extmod.mk
18+
19+
# The micropython-lib submodule is not needed by this project, but the MicroPython
20+
# build system requires it if FROZEN_MANIFEST is set (which it is below). To avoid
21+
# needing to check out the micropython-lib submodule, point MPY_LIB_DIR to a dummy
22+
# location that has a README.md file.
23+
MPY_LIB_DIR = $(TOP)
1724

1825
MP_VER_FILE = $(HEADER_BUILD)/mpversion.h
1926
MBIT_VER_FILE = $(HEADER_BUILD)/microbitversion.h
@@ -107,7 +114,7 @@ SRC_C += \
107114
$(abspath $(LOCAL_LIB_DIR)/sam/debug.c) \
108115

109116
SRC_O += \
110-
shared/runtime/gchelper_m3.o \
117+
shared/runtime/gchelper_thumb2.o \
111118

112119
OBJ = $(PY_O)
113120
OBJ += $(addprefix $(BUILD)/, $(SRC_O))
@@ -138,5 +145,3 @@ $(BUILD)/py/stackctrl.o: CWARN += -Wno-dangling-pointer
138145
$(BUILD)/$(abspath $(LOCAL_LIB_DIR))/sam/sam.o: CWARN += -Wno-array-bounds
139146

140147
include $(TOP)/py/mkrules.mk
141-
142-
CLEAN_EXTRA += $(LIBMICROPYTHON)

src/codal_port/drv_display.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@ void microbit_display_animate(mp_obj_t iterable, mp_int_t delay, bool clear, boo
192192
wait_for_event();
193193
}
194194
}
195+
196+
MP_REGISTER_ROOT_POINTER(void *display_data);

src/codal_port/drv_radio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,5 @@ void microbit_radio_pop(void) {
283283
// Re-enable the radio IRQ.
284284
NVIC_EnableIRQ(RADIO_IRQn);
285285
}
286+
287+
MP_REGISTER_ROOT_POINTER(uint8_t *radio_buf);

src/codal_port/drv_softtimer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,5 @@ uint32_t microbit_soft_timer_get_ms_to_next_expiry(void) {
9898
}
9999
return dt;
100100
}
101+
102+
MP_REGISTER_ROOT_POINTER(struct _microbit_soft_timer_entry_t *soft_timer_heap);

src/codal_port/iters.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ static mp_obj_t microbit_repeat_iter_next(mp_obj_t iter_in) {
4242
return mp_obj_subscr(iter->iterable, MP_OBJ_NEW_SMALL_INT(iter->index), MP_OBJ_SENTINEL);
4343
}
4444

45-
const mp_obj_type_t microbit_repeat_iterator_type = {
46-
.base = { &mp_type_type },
47-
.name = MP_QSTR_iterator,
48-
.getiter = mp_identity_getiter,
49-
.iternext = microbit_repeat_iter_next,
50-
};
45+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
46+
microbit_repeat_iterator_type,
47+
MP_QSTR_iterator,
48+
MP_TYPE_FLAG_ITER_IS_ITERNEXT,
49+
iter, microbit_repeat_iter_next
50+
);
5151

5252
mp_obj_t microbit_repeat_iterator(mp_obj_t iterable) {
5353
repeat_iterator_t *result = m_new_obj(repeat_iterator_t);

src/codal_port/microbit_accelerometer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ STATIC const mp_rom_map_elem_t microbit_accelerometer_locals_dict_table[] = {
199199
};
200200
STATIC MP_DEFINE_CONST_DICT(microbit_accelerometer_locals_dict, microbit_accelerometer_locals_dict_table);
201201

202-
const mp_obj_type_t microbit_accelerometer_type = {
203-
{ &mp_type_type },
204-
.name = MP_QSTR_MicroBitAccelerometer,
205-
.locals_dict = (mp_obj_dict_t *)&microbit_accelerometer_locals_dict,
206-
};
202+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
203+
microbit_accelerometer_type,
204+
MP_QSTR_MicroBitAccelerometer,
205+
MP_TYPE_FLAG_NONE,
206+
locals_dict, &microbit_accelerometer_locals_dict
207+
);
207208

208209
const microbit_accelerometer_obj_t microbit_accelerometer_obj = {
209210
{ &microbit_accelerometer_type },

src/codal_port/microbit_button.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ STATIC const mp_map_elem_t microbit_button_locals_dict_table[] = {
6464

6565
STATIC MP_DEFINE_CONST_DICT(microbit_button_locals_dict, microbit_button_locals_dict_table);
6666

67-
const mp_obj_type_t microbit_button_type = {
68-
{ &mp_type_type },
69-
.name = MP_QSTR_MicroBitButton,
70-
.locals_dict = (mp_obj_dict_t *)&microbit_button_locals_dict,
71-
};
67+
MP_DEFINE_CONST_OBJ_TYPE(
68+
microbit_button_type,
69+
MP_QSTR_MicroBitButton,
70+
MP_TYPE_FLAG_NONE,
71+
locals_dict, &microbit_button_locals_dict
72+
);
7273

7374
const microbit_button_obj_t microbit_button_a_obj = {
7475
.base = { &microbit_button_type },

src/codal_port/microbit_compass.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ STATIC const mp_rom_map_elem_t microbit_compass_locals_dict_table[] = {
100100
};
101101
STATIC MP_DEFINE_CONST_DICT(microbit_compass_locals_dict, microbit_compass_locals_dict_table);
102102

103-
STATIC const mp_obj_type_t microbit_compass_type = {
104-
{ &mp_type_type },
105-
.name = MP_QSTR_MicroBitCompass,
106-
.locals_dict = (mp_obj_dict_t *)&microbit_compass_locals_dict,
107-
};
103+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
104+
microbit_compass_type,
105+
MP_QSTR_MicroBitCompass,
106+
MP_TYPE_FLAG_NONE,
107+
locals_dict, &microbit_compass_locals_dict
108+
);
108109

109110
const microbit_compass_obj_t microbit_compass_obj = {
110111
{ &microbit_compass_type },

0 commit comments

Comments
 (0)