[Solved] Getting PlatformIO working for Pokitto

A couple of seemingly random questions, the answers to which probably only @jonne will know:

  1. In terms of compiling code for the Pokitto, does the Pokitto require anything different (i.e. different settings, extra compile steps) from a standard LPC11U68?

  2. What is the suffix of the Pokitto’s official company title? (e.g. ‘Mojang’ is ‘Mojang AB’, ‘Nintendo’ is ‘Nintendo Co., Ltd.’ in the west and ‘Nintendo Kabushikigaisha’ in Japan)

1 no
2 Oy

1 Like

Thank you.


Ok, I can’t be bothered with being cryptic about what I’m trying to do.

I gave up on Code Blocks for now and decided to try PlatformIO again.

I discovered this:

Then I started making this:

But instead of going to all that trouble, I thought I’d see if I could get the regular LPC11U68 thing working on its own first.

After scrapping a large chunk of the Pokitto library, swapping out the .ld file and fixing one tiny redefinition issue with the LPC stuff I managed to compile a binary, but sadly it doesn’t work, the moment the Pokitto is turned on, it goes into flash mode.

firmware.bin (35.0 KB)

That file has no checksum. Are you using the latest LPC11U68.ld and startup_LPC11U68.cpp from the PokittoLib?

I had to replace LPC11U68.ld.link_script.ld with the LPC11U68.ld from the PokittoLib and I had to edit startup_LPC11U68.cppto mark __aeabi_atexit as inline, otherwise collect2.exe complains about multiple definitions.

I could try reverting the link file and marking __aeabi_atexit as WEAK instead.

It’s definitely all the latest stuff though, I only just set up PlatformIO today.
Prior to that I had VSCode installed but I’d never installed any extensions.

Does running the checksum generator over the .bin cause it to work properly?
If so that means we’re 80% of the way to having platformio working.

It should, if that’s all that is wrong. When I run it in ProjectABE I get a “Checksum mismatched! Expected: efff65c5 Found: 0” warning in the console, which would keep real hardware from booting.

The __aeabi_atexit error is strange. Maybe wrapping (-Wl,--wrap,_atexit) would fix it?

It’s not just the checksum, though that does appear to be part of the problem.
Seems the default LPC11U68 target doesn’t set the checksum.

Even after that though, it’s a white screen.
I’ll try playing with a few more files, I think I saw another .ld somewhere.

I’ve left __aeabi_atexit marked as weak for now.
It probably should be inline, the file has no #pragma once or include guards.


Worth noting that currently the .bin is 36KB versus the 34KB ejected by EmBitz.
And the .elf is 189KB vs EmBitz’s 607KB (though that could easily be a matter of debugging symbols being excluded or something).

Are you sure that’s the right libc?

It’s what got installed under ~\.platformio\packages\framework-mbed\targets\TARGET_NXP\TARGET_LPC11U6X\device\TOOLCHAIN_GCC_ARM\TARGET_LPC11U68.

Prior to me adding the weak attribute, everything up to line 173 100% matched what the PokittoLib copied locally.

(I got rid of all the stuff under mbed-pokitto because most of it was causing conflicts. I also got rid of POKITTO_SIM, POKITTO_XTERNALS, .hg and everything but Synth from POKITTO_LIBS.)

Except that (mbed-pokitto) is not the same mbed library you get through Platformio.

IIRC, because this was some 2 years ago, mbed and/or NXP had screwed up at some stage with the NVIC copy to RAM function. I fixed it by hand and informed them of the bug.

mbed-pokitto is by yours truly

EDIT: and now I recall what my pain with Platformio was. Getting the compiler to disregard the mbed library as provided by Platformio was very hard and would have required me to write the descriptions for a completely new target/platform

In that case, I’m going to try overriding all the default mbed source with the Pokitto versions.

If that works then that’s proof positive that writing descriptions for a new platform is the way forward.
They can be based on the LPC11U68 and just change all the details to do with NXP in favour of Pokitto (or at least as much as makes sense).

Oh. That’s genius… I’m embarrassed to say I didn’t even think of it. Just copy on top.

Tell us how it goes.

Genius or desperation? There’s a fine line :P


Wiping the existing files and then copying didn’t work, the terminal tried to reaquire them.

Copying on top has resulted in a list of errors.
I’m off to dinner, but I’ll leave the error dump here:

Processing lpc11u68 (platform: nxplpc; board: lpc11u68; framework: mbed)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: NXP LPC > LPCXpresso11U68
SYSTEM: LPC11U68 50MHz 36KB RAM (256KB Flash)
DEBUG: CURRENT(cmsis-dap) ON-BOARD(cmsis-dap) EXTERNAL(blackmagic, jlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 17 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Pokitto>
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\AnalogIn.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\BusIn.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\BusInOut.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\BusOut.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\CAN.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\Ethernet.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\I2C.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\I2CSlave.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\InterruptIn.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\RawSerial.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\SPI.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\SPISlave.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\Serial.o
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\SerialBase.o
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp: In constructor 'mbed::SPI::SPI(PinName, PinName, PinName, PinName)':
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp:41:21: error: 'SPI_FILL_CHAR' was not declared in this scope
_write_fill(SPI_FILL_CHAR) {
^~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp:41:21: note: suggested alternative: 'SPI_FILL_WORD'
_write_fill(SPI_FILL_CHAR) {
^~~~~~~~~~~~~
SPI_FILL_WORD
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp: In member function 'virtual int mbed::SPI::write(const char*, int, char*, int)':
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp:111:15: error: 'spi_master_block_write' was not declared in this scope
int ret = spi_master_block_write(&_spi, tx_buffer, tx_length, rx_buffer, rx_length, _write_fill);
^~~~~~~~~~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SPI.cpp:111:15: note: suggested alternative: 'spi_master_write'
int ret = spi_master_block_write(&_spi, tx_buffer, tx_length, rx_buffer, rx_length, _write_fill);
^~~~~~~~~~~~~~~~~~~~~~
spi_master_write
Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\Ticker.o
*** [.pioenvs\lpc11u68\FrameworkMbedCore\drivers\SPI.o] Error 1Compiling .pioenvs\lpc11u68\FrameworkMbedCore\drivers\Timeout.o

In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:19:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/TimerEvent.h:71:26: error: 'us_timestamp_t' has not been declared
void insert_absolute(us_timestamp_t timestamp);
^~~~~~~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SerialBase.cpp:19:0:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void sleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:158:20: error: 'void sleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void sleep(void)
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SerialBase.cpp:19:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:41:6: note: previous declaration of 'void sleep()'
void sleep(void);
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SerialBase.cpp:19:0:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void deepsleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:191:20: error: 'void deepsleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void deepsleep(void)
^~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\SerialBase.cpp:19:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:56:6: note: previous declaration of 'void deepsleep()'
void deepsleep(void);
^~~~~~~~~
*** [.pioenvs\lpc11u68\FrameworkMbedCore\drivers\SerialBase.o] Error 1
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:19:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/TimerEvent.h:71:26: error: 'us_timestamp_t' has not been declared
void insert_absolute(us_timestamp_t timestamp);
^~~~~~~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void sleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:158:20: error: 'void sleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void sleep(void)
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:41:6: note: previous declaration of 'void sleep()'
void sleep(void);
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void deepsleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:191:20: error: 'void deepsleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void deepsleep(void)
^~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:56:6: note: previous declaration of 'void deepsleep()'
void deepsleep(void);
^~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:16:0:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h: At global scope:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:115:43: error: 'us_timestamp_t' has not been declared
void attach_us(Callback<void()> func, us_timestamp_t t) {
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:139:38: error: 'us_timestamp_t' has not been declared
void attach_us(T *obj, M method, us_timestamp_t t) {
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:152:16: error: 'us_timestamp_t' has not been declared
void setup(us_timestamp_t t);
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:156:5: error: 'us_timestamp_t' does not name a type; did you mean 'timestamp_t'?
us_timestamp_t         _delay;  /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
^~~~~~~~~~~~~~
timestamp_t
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:37:20: error: variable or field 'setup' declared void
void Ticker::setup(us_timestamp_t t) {
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:37:20: error: 'us_timestamp_t' was not declared in this scope
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:37:20: note: suggested alternative: 'timestamp_t'
void Ticker::setup(us_timestamp_t t) {
^~~~~~~~~~~~~~
timestamp_t
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp: In member function 'virtual void mbed::Ticker::handler()':
C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Ticker.cpp:46:39: error: '_delay' was not declared in this scope
insert_absolute(event.timestamp + _delay);
^~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void sleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:158:20: error: 'void sleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void sleep(void)
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:41:6: note: previous declaration of 'void sleep()'
void sleep(void);
^~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h: In function 'void deepsleep()':
C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:191:20: error: 'void deepsleep()' was declared 'extern' and later 'static' [-fpermissive]
static inline void deepsleep(void)
^~~~~~~~~
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/platform/mbed_power_mgmt.h:26:0,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:23,
from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed\hal/sleep_api.h:56:6: note: previous declaration of 'void deepsleep()'
void deepsleep(void);
^~~~~~~~~
*** [.pioenvs\lpc11u68\FrameworkMbedCore\drivers\Ticker.o] Error 1
In file included from C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Timeout.h:19:0,
from C:\users\Pharap\.platformio\packages\framework-mbed\drivers\Timeout.cpp:16:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h: At global scope:
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:115:43: error: 'us_timestamp_t' has not been declared
void attach_us(Callback<void()> func, us_timestamp_t t) {
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:139:38: error: 'us_timestamp_t' has not been declared
void attach_us(T *obj, M method, us_timestamp_t t) {
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:152:16: error: 'us_timestamp_t' has not been declared
void setup(us_timestamp_t t);
^~~~~~~~~~~~~~
C:\users\Pharap\.platformio\packages\framework-mbed/drivers/Ticker.h:156:5: error: 'us_timestamp_t' does not name a type; did you mean 'timestamp_t'?
us_timestamp_t         _delay;  /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
^~~~~~~~~~~~~~
timestamp_t
*** [.pioenvs\lpc11u68\FrameworkMbedCore\drivers\Timeout.o] Error 1

I’m having another attempt at chipping away at it today.

I’ve been trying to get ~/.platformio/packages/framework-mbed to resemble something the Pokitto can use by frankenstein-ing PokittoLib/mbed-pokitto with it, but it seems like the files in framework-mbed are substantially different from the ones in mbed-pokitto and thus in constant conflict.

It makes me wonder how/why mbed-pokitto seems to be capable of working alright with EmBitz.

Any news on this?

Nothing yet. I stopped working on it for the last two days and worked on other things.

I hope to get back to it soon, but I think I’m going to have to do an awful lot of reading and reverse engineering if I’m going to have a chance at getting it working.

#AHAAAA!

I have managed to get Platformio to compile for LPC11U68 base target.

But: there is something wrong.

By using Segger Ozone debugger (thanks to Dirk at Segger) i have now found out that even if you compile a perfectly good program it will not run

There is some sort of a critical bug that stops the binary generated by a base LPC11U68 recipe. Nothing to do with PokittoLib!

SystemInitHook(); gets stuck for ever:

(by the way, this is one crazy powerful debugger. highly recommend)

I told them to fix this code. mbed-pokitto works precisely because of this same fix.

Then they apparently fixed it their way, and made a sloppy, sloppy bug in its place.

software_init_hook is a void function that copies the NVIC vectors to RAM and then returns. There is no way if (software_init_hook) ever is false (because it is the address of the function), therefore it is eternally stuck in this place.

Speechless.

Going to continue fixing this tomorrow.

But, now we probably know the solution:

  • startup_LPC11U68 needs to be replaced with a working one
1 Like

#nope

That is the problem but my analysis is wrong.

I need to understand what else has changed.

in fact, it is even annoying and more sloppy than I thought

It jumps to a non-existent (weak) software_init_hook_rtos and runs to the end

Nobody bothered with a check whether were building a rtos build or not :scream: