-
Yup, I do however think that we should find a way of debugging when it actually goes to deepsleep. Not sure how to do that yet, because now the terminal is only available if it doesn't go to deepsleep.
The way I have it now is actually kind of sweet for that, because it allows me to go to deepsleep and still print stuff whenever I want (it can't accept anything though, just print). For example:
Also, I updated the timekeeping function, and you can now see that the clock-example is operating much more energy efficiently (spending much less time awake):
-
The Energy Profiler is included in Simplicity Studio, and yes, it uses the hardware that's on all the Gecko starter kits. While originally only for Gecko devices, you can use it to profile any other device you want.
No, the USB->Serial is just a plain UART. I think the long term solution is to move it to the in-device USB, not sure if it makes too much sense to spend time on implementing something in-between.
-
Thought I'd do a quick write-up on how to get Espruino up running on the EFM32:
So, after a couple of nights I got the basic support running. It supports timekeeping in EM2, wake-ups from EM2 and basic flashing and communication. If you want to try it out, download the attached binary and flash it on your Giant Gecko starter kit. Then open the web IDE and connect to the COM-port of the kit.
If you want some simple examples, you can for example try:
var state=0; function led_swap() { state = !state; LED1.write(state); } setWatch(led_swap, BTN1, {edge:'falling',repeat:true}); setDeepSleep(true);
Or:
var Clock = require("clock").Clock; var clk = new Clock(2016,0,27,17,0,0,0); function setLed() { LED1.write(clk.getDate().getSeconds() & 0x1); LED2.write(clk.getDate().getSeconds() & 0x2); } setInterval(setLed,1000); setDeepSleep(true);
If you ever save something to flash (using save()) or send it to EM2 and want to recover the console, just hold down BTN1 (marked as PB0 on the kit) when resetting. There's also a bug that caused the console not to recover after loading from or saving to flash.
Here's two Energy Profiler shots of the examples above:
Example 1, You can see it's using about 2.8 uA when waiting for pin-wakeup and the LED consuming ~0.5mA. You can also see that it actually triggers on both edges (rising & falling) with Espruino validating the trigger.
Example 2:
Again, you can see normal timekeeping at 2.8 uA, and the LEDs consuming 0.5 mA each..
If you want to save something with
setDeepSleep()
I recommend using the below stub to go to deep sleep after 5 secs, so you have enough time to typesave()
after uploading the code://Go to deep sleep after 5 secs, so we have time to do save() setTimeout(function() {setDeepSleep(true)}, 5000);
Lastly, if you want to contribute just get the code from github, there is a Simplicity Studio project located in the targets/efm32 folder. What's currently missing:
- PWM
- SPI
- Analog functionality
- Serial over USB (Right now it's using the serial over the debug USB-cable. Should move this to the on-chip USB)
- PWM
-
-
-
Thanks for the info!
It wakes properly to tell me the time every 10 seconds, so I guess so..? Pin wake-up is not yet implemented.. I'm also having a bit of trouble testing the utility timer and Delay() functions. Do you have some simple test-cases for the framework?
The EFM32 have USB, but it's not implemented yet :) Actually that touches another comment. If a device has USB,
USB
is usually defined. I would consider moving the define for the VCP to a more descriptive define, as some devices in the future will have USB but chose not to implement it.I actually had to change the part-number of the EFM32 to one without USB to make it compile.
-
Where is this set
(jsiStatus & JSIS_ALLOW_DEEP_SLEEP)
?I've finished implementing the deep sleep functionality so it sleeps for real if waiting for things that take more than 1/2 second but I have to comment out the above line. Of course then the console does not work very well :)
I can't see the above flag being set for jsiStatus anywhere? Guessing that it should only be set when a console is not connected?
Also, on another note, if I want to use 115200 baud for the console, how do I do it (on the PC side)?
-
Hi,
You guys probably know this already, but I'm just posting the update for further reference if anyone else runs into the same problem. The Undefined reference to `_etext' is because _etext is being used directly from jswrap_process.c here:
extern int LINKER_ETEXT_VAR; // end of flash text (binary) section
. This define is located in platform_config.h produced by build_platform_config.py.The reason for the mismatch is that the EFM32 linker (and startup-file) defines this variable as __etext (notice two underscores). So after updating the build_platform_config.py to use this name instead for the LINKER_ETEXT_VAR it's all good.
The other undefined references to _sbrk and _exit was solved by adding
-Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
to the linker options for the EFM32. -
Woah!
It's working. Basically the whole setup was correct including the linker file for the EFM32, but I hadn't guarded the generation of the linker file
$(LINKER_FILE): scripts/build_linker.py
, so it would overwrite it. Took me a bit to figure that out. We should maybe add a more generic guard around that for other targets that wants to use their own linker file.Then, ran into the problem of ALWAYS_INLINE, but setting
DEBUG=1
solved it (by skipping the attribute).Right now it's compiling and running, but currently when including the
jsvInit();
in main.c, causes the compiler to exit with undefined reference to `_sbrk' and undefined reference to `_etext'. Probably no biggie, so will see how it goes. -
Hi,
Thanks for the suggestion.
RELEASE=1 PICO_1V3=1 make
works fine. Yields a file of 304480 bytes.Building for the EFM32 with a makefile also works fine, the mbed output above comes from doing just that. Also, the Gecko SDK comes with all examples created for ARM GCC, and they're all building fine.
We have two dev-environments here. Me (the Windows n00b) and Mikael running make in Dokker on a Mac. Both have the same problems. I was just hoping that there would be some GCC wiz here that would immediately spot my mistake, but I guess I'll just have to start at the beginning, removing files and options from the building till it starts working :)
-
Good tip!
Here's the mbed compiled with gcc:arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-p ointer -MMD -MP -DNDEBUG -Os -DEFM32GG990F1024 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_G CC -DTARGET_CORTEX_M -DTARGET_Silicon_Labs -DARM_MATH_CM3 -DMBED_BUILD_TIMESTAMP =1450779582.39 -DTARGET_EFM32 -D__CORTEX_M3 -DTARGET_M3 -DTARGET_EFM32GG_STK3700 -D__MBED__=1 -std=gnu++98 -fno-rtti -I. -I./mbed -I./mbed/TARGET_EFM32GG_STK37 00 -I./mbed/TARGET_EFM32GG_STK3700/TARGET_Silicon_Labs -I./mbed/TARGET_EFM32GG_S TK3700/TARGET_Silicon_Labs/TARGET_EFM32 -I./mbed/TARGET_EFM32GG_STK3700/TARGET_S ilicon_Labs/TARGET_EFM32/TARGET_EFM32GG_STK3700 -I./mbed/TARGET_EFM32GG_STK3700/ TARGET_Silicon_Labs/TARGET_EFM32/emlib -I./mbed/TARGET_EFM32GG_STK3700/TARGET_Si licon_Labs/TARGET_EFM32/emlib/inc -I./mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ ARM -o main.o main.cpp arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=bin/mbed_blinky_low_po wer.map,--cref -T./mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/efm32gg.ld -L./ mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM -o bin/mbed_blinky_low_power.axf main.o mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/board.o mbed/TARGET_EFM32GG _STK3700/TOOLCHAIN_GCC_ARM/cmsis_nvic.o mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GC C_ARM/mbed_overrides.o mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/retarget.o mbed/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/startup_efm32gg.o mbed/TARGET_EFM3 2GG_STK3700/TOOLCHAIN_GCC_ARM/system_efm32gg.o -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
Here's the standard compilation using Simplicity Studio:
Building file: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c Invoking: GNU ARM C Compiler arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m3 -mthumb '-DDEBUG_EFM_USER=1' '-DEFM32GG990F1024=1' '-DDEBUG=1' -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/EFM32GG_STK3700/examples/usbdhidkbd" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/EFM32GG_STK3700/config" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/CMSIS/Include" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/emlib/inc" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/bsp" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/drivers" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Include" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/usb/inc" -O0 -Wall -c -fmessage-length=0 -mno-sched-prolog -fno-builtin -ffunction-sections -fdata-sections -std=c99 -MMD -MP -MF"CMSIS/efm32gg/system_efm32gg.d" -MT"CMSIS/efm32gg/system_efm32gg.o" -o "CMSIS/efm32gg/system_efm32gg.o" "C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c" Finished building: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.S Finished building: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/drivers/segmentlcd.c Building file: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/bsp/bsp_trace.c Invoking: GNU ARM C Compiler arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m3 -mthumb '-DDEBUG_EFM_USER=1' '-DEFM32GG990F1024=1' '-DDEBUG=1' -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/EFM32GG_STK3700/examples/usbdhidkbd" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/EFM32GG_STK3700/config" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/CMSIS/Include" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/emlib/inc" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/bsp" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/drivers" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Include" -I"C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/usb/inc" -O0 -Wall -c -fmessage-length=0 -mno-sched-prolog -fno-builtin -ffunction-sections -fdata-sections -std=c99 -MMD -MP -MF"BSP/bsp_trace.d" -MT"BSP/bsp_trace.o" -o "BSP/bsp_trace.o" "C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/bsp/bsp_trace.c" Finished building: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c Finished building: C:/SiliconLabs/SimplicityStudio/v3/developer/sdks/efm32/v2/kits/common/bsp/bsp_trace.c Building target: STK3700_usbdhidkbd.axf Invoking: GNU ARM C Linker arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m3 -mthumb -T "STK3700_usbdhidkbd.ld" -Xlinker --gc-sections -Xlinker -Map="STK3700_usbdhidkbd.map" --specs=nano.specs -o STK3700_usbdhidkbd.axf "./src/descriptors.o" "./src/main.o" "./emusb/em_usbd.o" "./emusb/em_usbdch9.o" "./emusb/em_usbdep.o" "./emusb/em_usbdint.o" "./emusb/em_usbhal.o" "./emusb/em_usbtimer.o" "./emlib/em_assert.o" "./emlib/em_cmu.o" "./emlib/em_ebi.o" "./emlib/em_emu.o" "./emlib/em_gpio.o" "./emlib/em_int.o" "./emlib/em_lcd.o" "./emlib/em_system.o" "./emlib/em_timer.o" "./emlib/em_usart.o" "./Drivers/hidkbd.o" "./Drivers/segmentlcd.o" "./CMSIS/efm32gg/startup_efm32gg.o" "./CMSIS/efm32gg/system_efm32gg.o" "./BSP/bsp_trace.o" -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group Finished building target: STK3700_usbdhidkbd.axf Building hex file: STK3700_usbdhidkbd.hex arm-none-eabi-objcopy -O ihex "STK3700_usbdhidkbd.axf" "STK3700_usbdhidkbd.hex" Building bin file: STK3700_usbdhidkbd.bin arm-none-eabi-objcopy -O binary "STK3700_usbdhidkbd.axf" "STK3700_usbdhidkbd.bin"
And here's the output from the Espruino building at the moment:
arm-none-eabi-gcc -Wall -Wextra -Wconversion -Werror=implicit-function-declaration -fno-strict-aliasing -Wno-sign-conversion -Wno-conversion -Wno-unused-parameter -std=c99 -Os -fno-common -fno-exceptions -fdata-sections -ffunction-sections -flto -fno-fat-lto-objects -Wl,--allow-multiple-definition --param inline-unit-growth=6 -c -mcpu=cortex-m3 -mthumb -g -gdwarf-2 -DGIT_COMMIT=bdfda3e6cc2fb0083a77aa1fdebe77887fcf4821 -DBUILDNUMBER="52" -DEFM32GG990F1024 -DUSE_DEBUGGER -DUSE_MATH -DARM -DLINK_TIME_OPTIMISATION -DEMBEDDED -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targets -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/src -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/gen -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/libs/math -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/cmsis/Include -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targets/efm32 -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Include -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emdrv/nvm/inc -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emdrv/rtcdrv/inc -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emdrv/common/inc -I/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/inc gen/jswrapper.c -o gen/jswrapper.o arm-none-eabi-gcc -Winline -Os -fno-common -fno-exceptions -fdata-sections -ffunction-sections -flto -fno-fat-lto-objects -Wl,--allow-multiple-definition --param inline-unit-growth=6 -mcpu=cortex-m3 -mthumb -g -gdwarf-2 -Wl,--gc-sections -T/c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Source/GCC/efm32gg.ld -o espruino_1v84.52_efm32ggstk.elf src/jslex.o src/jsvar.o src/jsvariterator.o src/jsutils.o src/jsnative.o src/jsparse.o src/jspin.o src/jsinteractive.o src/jsdevices.o src/jstimer.o src/jsspi.o gen/jswrapper.o libs/math/acosh.o libs/math/asin.o libs/math/asinh.o libs/math/atan.o libs/math/atanh.o libs/math/cbrt.o libs/math/chbevl.o libs/math/clog.o libs/math/cmplx.o libs/math/const.o libs/math/cosh.o libs/math/drand.o libs/math/exp10.o libs/math/exp2.o libs/math/exp.o libs/math/fabs.o libs/math/floor.o libs/math/isnan.o libs/math/log10.o libs/math/log2.o libs/math/log.o libs/math/mtherr.o libs/math/polevl.o libs/math/pow.o libs/math/powi.o libs/math/round.o libs/math/setprec.o libs/math/sin.o libs/math/sincos.o libs/math/sindg.o libs/math/sinh.o libs/math/sqrt.o libs/math/tan.o libs/math/tandg.o libs/math/tanh.o libs/math/unity.o targets/efm32/main.o targets/efm32/jshardware.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emdrv/rtcdrv/src/rtcdriver.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_assert.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_cmu.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_emu.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_gpio.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_msc.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_rtc.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_system.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_timer.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/emlib/src/em_usart.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/gen/jspininfo.o src/jswrap_array.o src/jswrap_arraybuffer.o src/jswrap_date.o src/jswrap_error.o src/jswrap_espruino.o src/jswrap_flash.o src/jswrap_functions.o src/jswrap_interactive.o src/jswrap_io.o src/jswrap_json.o src/jswrap_modules.o src/jswrap_pin.o src/jswrap_number.o src/jswrap_object.o src/jswrap_onewire.o src/jswrap_pipe.o src/jswrap_process.o src/jswrap_serial.o src/jswrap_spi_i2c.o src/jswrap_stream.o src/jswrap_string.o src/jswrap_waveform.o libs/math/jswrap_math.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.o /c/Users/apsyvert/Documents/work/github/Espruino_SL/Espruino/targetlibs/Gecko_SDK/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.o arm-none-eabi-objcopy -O binary espruino_1v84.52_efm32ggstk.elf espruino_1v84.52_efm32ggstk.bin bash scripts/check_size.sh espruino_1v84.52_efm32ggstk.bin PASS - size of 0 is under 1016957 bytes arm-none-eabi-objcopy -O ihex espruino_1v84.52_efm32ggstk.elf espruino_1v84.52_efm32ggstk.hex
I'm totally lost in terms of GCC at the moment. Posting this in a desparate hope that someone might be able to spot the errors...
-
Thanks!
Yup, that's what I'm working on. Just getting a toolchain up running and making main.c blink a LED.
But bargh. I'm doing some headbashing here. Basically the Silicon Labs development tools (Simplicity Studio) is based on Eclipse+GCC so it shouldn't be that hard to get it up running right?
We don't supply these startup-files as objects, only as assembly or C-files, so if the build system is expecting that I understand that they might be causing problem...?
I tried using a pre-defined linker file, and setting the object-file generated from startup_efm32gg.c to a PRECOMPILED_OBJS. Still no luck. Any other suggestions on what might be wrong?
I'm using GNU ARM 4.8_2013q4
-
Hi,
I'm on my way to porting Espruino to the EFM32 series of microcontrollers..
I guess I will have more, but right now I have three questions:
1) What is the boardname_af.csv used for? I can't seem to find what files are generated from that file..
2) Right now the target compiles, but the output binary is 0 bytes. Any pointers to what might have happened?
3) Which IDE are you guys usually using when developing the target code? Any pre-made projects for any IDE?
No, it was just me doing a sloppy integration the first time, with only 1 second resolution on the
jshGetRTCSystemTime()
. This caused it to wake up, then wait for the 1 second tick, so it could update the LEDs. The time it actually spent awake was highly dependent on the sync between the sleep-timer and the 1 second tick.Now that the
jshGetRTCSystemTime()
has sub-ms resolution it wakes up and immediately sees that it's the time to update the LEDs.