Requests


This page is for you! If you’d like more information about something I’ve posted about, or if there is a topic you think I should post about, please leave a comment and I’ll get right to it (as fast as my schedule permits it)!

I have started to list things in my bucket list (still ongoing).

For feature requests or bug reports on the McuOnEclipse project end Processor Expert components, you should use the GitHub issue tracking system:

932 thoughts on “Requests

  1. Eric,

    I have followed your guide for porting PEx to MCUXpresso as shown here: https://mcuoneclipse.com/2018/07/27/porting-processor-expert-projects-to-mcuxpresso-ide/

    I’ve tried multiple times, however, I keep running into an error something to do with the vector files. The error it describes is, “undefined reference to `__thumb_startup’ within the vectors.o resource. I am using the MK22FN256LVH12. Not quite sure why it would not be defined since when I search for its source it goes to this.

    #elif defined(__GNUC__)
    #ifdef __cplusplus
    extern “C” void __thumb_startup( void );
    #else
    extern void __thumb_startup( void );
    #endif

    Thoughts?

    Like

    • Hi Chris,
      you might have a look at https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/MCUXpresso/tinyK22/tinyK22_RoomMonitor as a reference.

      It looks like you still have __thumb_startup in Vectors_Config.h?

      ‘undefined reference’ means that the function is not defined (implemented) anywhere.
      Check that the ‘startup/startup*.c’ file is indeed compiled and linked. The entry point of the reset vector with the SDK is ResetISR() inside that startup file.
      Now the _thumb_startup() one is the startup name for KDS and usually referenced from the vectors file.
      You need to change the ‘Static_code\System\Vectors.c’ (which it seems you have found). A few lines below there is
      VECTOR_1, /* 0x01 ivINT_Initial_Program_Counter */
      which means you need to change the definition of VECTOR_1which is in Generated_Code\Vectors_Config.h

      /* Vector Address No. Pri Name Description */
      #if 0 /* original Processor Expert code */
      #define VECTOR_SP_MAIN &__SP_INIT /* 0x00 – ivINT_Initial_Stack_Pointer used by PE */
      #define VECTOR_1 (tIsrFunc)&__thumb_startup /* 0x01 – ivINT_Initial_Program_Counter used by PE */
      #else /* needed by SDK startup */
      #define VECTOR_SP_MAIN &_vStackTop /* 0x00 – ivINT_Initial_Stack_Pointer used by PE */
      #define VECTOR_1 (tIsrFunc)&ResetISR /* 0x01 – ivINT_Initial_Program_Counter used by PE */
      #endif

      I hope this helps?
      Erich

      Like

  2. Erich, Your posts are always the most helpful in filling the gaps between the theory and practice! Thank you for that. I would love if you covered the topic of end-user OS updating in the field. It looks like there may be two existing options for the IMXRT: MCUBoot/Flashloader or OpenSDA/DAP-Link (which requires a co-processor?)

    Thanks!

    Like

    • The DAP-Link (or debug port) is more for debugging and development, but not for updating systems in the field. Sure you can use it for that as well, but this requires better trained operators. The bootloader/flashloader is more intended for such an update process if you have physical access to the system. Other ways are using a network link for this.

      Like

  3. Hi Erich
    I found your blog very useful. Thank you a lot to share your experiences.
    Now i would ask you for a suggestion, maybe you are interested in writing a tutorial too.
    I’m using an iMX RT1050 EVKB with MCUxpresso.
    Everything is fine, every SDK example works fine while I run it alone.
    I tried then to build up my own application, but the same is if i try to merge up two samples to have at the same time lcdif (Rocktech part) and lwip.
    It looks like i misconfigured something, it always crash in hardfault handler routine.

    I also followed your article https://mcuoneclipse.com/2018/08/12/tutorial-open-source-embedded-gui-library-littlevgl-with-i-mx-rt1050-evk/
    Very impressive library!
    Cause your code already include freeRTOS, I managed to add ethernet there. I configured pins, includes, preprocessor, etc but no way to see it works.
    Can you help me in some way?

    Best regards,

    -Francesco-

    Like

  4. Hi Erich

    First of all thanks for the interesting website so its been one of the most useful ones for someone like me getting familiar with the Kinetis stuff. I have to learn Kinetis as I am working with a KL27 based board.

    The frustration I am having with KSDK is that the documentation shows 2016 on the website but the actual API seems to have changed and the documentation feels very sparse like its geared to someone who knows the products historically unlike ST Micro which feels a lot easier to get going with or is this just me? An example of such a change is that the SDK function GPIO_SetPinsOutput() seems to have been renamed as GPIO_PortSet() in the latest SDK downloaded from the builder and I had to read the source to figure out why my code wasnt compiling from the KDSK API documentation

    I need to get the LPUART to work and in order to do that I am not sure what clock setting to use in the LPUART_Init() function call.

    This is mostly due to the fact that its taking a lot of reading getting my head around the clocking on the device, I am starting to understand it but its heavy going and quite honestly feels like too much detail has to be understood to use the peripheral drivers. I will give kudos to NXP on the config tool as its very helpful and espscially the clock diagram helps in understanding, albeit the tool cannot do peripherals for the KL27.

    Do you have any advice on clock setup. It would be great if you could do a mini tutorial on clocking architecture in the Kinetis devices. I have used the Config Tool with MCUExpresso and have tried setting the following:

    MCGPCLK as IRC48M
    MCGIRCLK is 8Mhz

    so Core and System clocks are 48Mhzand the Bus and Flash clocks are 24Mhz and OSCERCLK and ERCLK32K as well as RTC_CLKOUT are all disabled.(all setup by the clock_config files exported from the Config Tools)

    I then call LPUART_Init() with a clock value of 8000000U and call the LPUART_EnableTx() in my main() program enter a loop and try sending a byte out continously without any activity on the other side.

    Do you have any advice?

    Like

    • Hi Peter,
      thanks, and you raise several good points and challenges I’m facing too. As for the ‘documentation’ I’m basically stick to the sources. I know it is not ideal. The thing with the GPIO_SetPinsOutput() and GPIO_PortSet() has hit me too. I have now a define in my library for the SDK version used (see https://github.com/ErichStyger/McuOnEclipseLibrary and the recent post https://mcuoneclipse.com/2019/01/27/tutorial-hd44780-display-driver-with-nxp-mcuxpresso-sdk/ where I use that library). Using that library I can keep some kind of thin abstraction layer between the SDK and the application. Best of all: I can mix and match the SDK with the NXP Processor Expert and MCUXpresso Configuration Tools :-).
      On the clocking: the Clocks Tool definitely helps, but one still has to read all the reference manual information. What I found it easier to use and understand is Processor Expert (but this is not supported for KL27). So I use it PEx for KL25Z or KL26Z and from this I apply my clock settings to the KL27Z. I have a few KL27Z boards around, but I have not used the KL27Z in an active project mainly because lack of Processor Expert support and limited RAM amount on the device (the K22F is right now what we are using a lot, but that’s a much larger MCU (and has PEx support)). Writing a tutorial for KL27Z certainly is technically doable, it is just that spare time is very limited, and I’m already struggling with getting all the material ready for the next semester…

      Like

  5. Possibly this is OT for ‘Requests’ but I respect the knowledge-base here on MCUonEclipse so I hope some advice is available.
    I’m looking for a good combination of ARM micro plus a Wifi connection. This is for a datalogging application. On the micro side I will collect data at a low rate for days or weeks, and use an SD card for storage.
    There are a number of simple Wifi solutions but all seems to use a UART or SPI connections to communicate with the host micro. I am looking for as fast as possible download, and these connections would represent a bottleneck.
    Is anyone aware of a simple Wifi solution that offers a faster connection? Many ARM micros offer a USB host or Ethernet peripherals these days, if there is something compatible with these it would be great to know about.
    Thanks, Ian

    Like

    • Hi Ian,
      I don’t think this is not OT (Off-Topic) at all.
      I have to say that all my WiFi ‘attached to micrcontroller’ projects have used UART and SPI.
      I started playing with ESP32, but not to a solid state yet. If you are not aware of ESP32, you might have a look into that device.
      You get WiFi with a microcontroller in one package. I don’t think that attaching this to USB/Ethernet ist probably not a good way.
      But just in case, as a ‘big’ solution: why not using a Raspberry Pi 3 Model B+ or similar? You get Quad Core ARM Cortex-A with SD card and WiFi 🙂

      Like

      • Thanks Erich,
        For reliability & robustness reasons I want to acquire the data using a micro (bare metal / RTOS) rather than a Linux device. The Wifi element is a convenience for the user – should the Wifi fail the logger data can be recovered manually by opening the sealed case and extracting the SD card.
        The Raspberry B+ is too big but I have seriously considered a ZeroW. Two concerns: 1) how to interface to the micro using a faster method than UART / SPI and 2) how robust these Linux devices are to power supply shutdown without corrupting their Linux install.
        Regarding ESP32 there seem to be a vast number of different carrier boards and modules available. So many that it’s hard to know where to start, and how long they’ll be around for… Maybe I just need to forget about longevity of supply and jump into some R&D…
        Thanks, Ian

        Like

  6. A quick general C question that I can’t find an answer for on the interwebs.
    I have a trace function which is basically printf with a bitmask:
    traceWrite(u32 conditionMask, char* str) {if (condition(conditionMask) printf(str);}
    There is also one for variable length:
    traceWriteF(u32 conditionMask, char* format, …) {if (condition(conditionMask) variadicstuff…;}
    But I hate having to have 2 functions, one for single, one for formatted. Does anyone know the trick to combine each of these? Somehow printf magically manages it, not sure if it’s a ‘special’ or not.
    Grateful for any help. Thanks 🙂

    Like

      • Yeah the format version of traceWrite, traceWriteF, uses varargs. I suppose what I want is to be able to do as printf does:
        printf(“a string”);
        printf(“show me %s”, theString);
        Somehow even though it uses varargs too, it deals with the single param case. My code throws an error if I use traceWriteF with a single string param.

        UPDATE: I’ve just tried compiling this again (it’s been years since I mucked with it) and now it seems to work. I don’t know what changed; perhaps a warning level?
        Looks like there is no problem after all. I’m so sorry to have wasted your time. Thanks for the response though.
        😦
        (runs and hides in cupboard…)

        Like

        • Happens to me too :-).
          One note: it is very important to include the header file for interfaces, especially for interfaces with open argument lists.
          Not following that is bad and can lead to strange things.

          Like

        • Absolutely. I elevate all warnings to errors (-Werror) which seems to enable implicit-function-declaration errors, among other things (is that what you meant?). I’d rather fight with a slightly pedantic compiler than have sloppy code come back and bite be later on.

          Like

  7. Erich,
    I’d like to get your opinion on a new problem that cropped up.
    I’ve been using the MK40DN512Z CPU for several years with Processor Expert.
    Now, NXP is discontinuing this version of the CPU and replacing it with MK40DN512.
    The old chip had Mask 4N30D and the new chip has Mask 5N22D.
    My existing code fails with the new chip (HARD FAULT) in cpu.c on the instruction that checks the mask.
    I’ve checked the Errata documents for both parts and there don’t appear to be any reasons that I cannot interchange them.
    Is there a Processor Expert solution to accepting either Mask?
    If not, how do you recommend modifying the PEx-generated code to make this work with both chips?
    Thanks,
    Greg

    Like

    • Hi Greg,
      I quickly created a project for the K40dN512Z, and I don’t see code in the CPU.c checking the CPU mask version? Did I miss it?
      I have not used the K40 for a long time: I used it at the beginning where the silicon had several issues. I was dealing with this with disabling code generation.
      So you could disable the code say for the cpu component and make your modifications as needed, and they don’t get overwritten.
      Have a look in https://mcuoneclipse.com/2012/03/23/disable-my-code-generation/

      I hope this helps,
      Erich

      Like

      • Erich,
        I thought you might enjoy what I found.
        The different mask value had nothing to do with the Hard Fault.
        Rather, CPU.c sets the RESET pin filtering values in SIM_SOUT6 for the MK40DN512ZVLL10.
        There is NO SIM_SOUT6 register in the MK40DN512VLL10.
        Thus the Hard Fault when accessing it.
        The wisdom of that change escapes me.
        Greg

        Like

        • Interesting, thanks for reporting back. I guess this is because that silicon was one of the very first and they seem to have changed that?

          Like

    • Hi Greg,
      I have not made a formal comparison. But CMSIS-RTOS is a wrapper or common API to different RTOS, and this only makes sense if I would like to use different RTOS (FreeRTOS, RTX, etc) in my applications (which I don’t intend to do). So from a user perspective it does not make sense to me. And it adds more complexity and with the wrapper it hides things, potentially not using all features. So I prefer directly to use the FreeRTOS API.
      It *does* make sense for a middleware vendor (e.g. a vendor selling a USB stack), as with this the stack could use CMSIS-RTOS to make it generic. But typically the interfaces are very thin, so it makes sense for them to use directly the FreeRTOS API or provide generic hooks (as lwIP or FatFS does) and go with it.
      I have not seen any real adoption in the market of CMSIS-RTOS except from ARM directly, maybe I’m wrong?

      Erich

      Like

  8. Ich habe das Projekt “ESP Wetterstation mit Farb-TFT” von Squix.org nachgebaut. Nun würde ich es gerne in ein Gehäuse einbauen. Leider habe ich keinen 3D-Drucker.
    Auf der Suche nach einem Gehäuse habe ich eines von Ihnen gefunden:
    https://mcuoneclipse.com/2017/09/10/wifi-tft-touch-lcd-weather-station-with-esp8266/comment-page-1/?unapproved=154363&moderation-hash=c0c42f6e3da679ac368b63fcd4d8cba0#comment-154363

    Wo kann ich dieses bestellen? Es gefällt mir sehr gut.

    Like

  9. Vielen Dank für die schnelle Antwort.
    Damit ich einen Laser-Cut machen lassen kann, benötige ich doch sicherlich eine Datei mit den Druckvorlagen für das gewünschte Gehäuse. Gibt es für Ihr Gehäuse so eine Datei für den Laser-Cutter?

    Like

  10. Hi Eric
    I saw your comment on Rob’s Sand bot. So I followed your avatar and ended up here.
    Boy!! it looks like you are a raspberry pi pro.
    I am also busy with my sand table build. Made it through al the pitfalls because I am not a programmer but more a handy builder. Ever since I saw the sisyphus it was a dream to own one. But as you know they are soooooo expensive. Are you planning to change the software or maybe port the code to a raspberry pi? That Would be great update. Rob’s software UI is OK but not very user friendly.
    I am busy making the actual table part now with a diameter of 1200mm. Electronics and mechanics is done and working. I used larger hybrid steppers and drivers for my table. Little more expensive but very quiet. Well worth the extra.

    Like

    • Glad to see you have found me :-). I’m actually not planning to use a Raspberry Pi, but instead a ARM Cortex-M4F microcontroller. I was inspired by the Sisyphus too, and first I was considering a XY solutionn. Digging more into the topic and because I plan a round table, I found Rob’s sand bot which works in a similar way as the Sisyphus. What Hyrid steppers are you using? I just ordered normal ones, and I hope the enclosure will keep it quit.
      I plan to use Sandify (https://github.com/jeffeb3/sandify) for pattern generation.

      Like

  11. Hi Eric,
    I’m using FreeRTOS in PEx on Kinetis. We’ve started having random crashes which I’ve narrowed down to vsnprintf (def in EWL cstdio), which is used for debug outputs. I’m not sure what it does behind the scenes but it smells like a stack overflow. I’m passing it a 512b static buffer, and it still hangs printing “%02X” type strings (i.e., very short). I’m guessing it’s dynamically allocating memory somewhere and having a problem there. Do you have any comments on the use of this function, or alternative implementations that might be safer than the bundled one?
    Apologies if this way out of scope for this thread. Thanks.

    Like

      • Many thanks Erich, that makes sense. I ended up using a combination of printf-stdarg.c I found floating around the web, and using inspiration from XFormat to support the (previously missing) float support. Works well enough, doesn’t crash anymore. Happy to share the source.
        I also might look at moving away from EWL; can you help me understand why you don’t recommend it and what you’d suggest as a best alternative?
        TIA

        Like

        • I try to avoid standard libraries as much as I can because the problems you have faced. Additionally using EWL makes a project not portable to another platform, and you cannot use it for a part from a different vendor. That’s why I stick to things like newlib-nano which does not have that limitation and still is decent in its implementation.

          Like

  12. Hi Erich,
    Do you know of any Eclipse add-ons for plotting variable array contents?
    I’m currently using Codewarrior (planning to transition to MCUXpresso eventually).
    I use the DSP tools in CMSIS for the Arm Cortex-M4 and debugging is laborious. When I need to check intermediate DSP results I stop at a breakpoint, expand the array in the debugger and copy-paste the values into Excel to create a plot. Sometimes it’s thousands of values at a time.
    I’d love to be able to click on the variable name and have Eclipse produce a plot for me directly.
    Anything out there that could help simplify this task?
    Thanks,
    Greg

    Like

  13. Hi Eric,
    I’m using FreeRTOS in PEx on Kinetis. I’m trying to tracking down code from a tasks executing code it shouldn’t run (non-ui task); not as simple as looking through the code unfortunately. I’m trying to see which task a routine is being called from. I’ve found configUSE_TRACE_FACILITY but still haven’t been able to use it to find the ‘current task’. I know the task handles returned from FRTOS1_xTaskCreate so I can identify each task. Any hints you can give me to help me achieve this please? It all just seems considerably complex for something that sounds simple.
    Many thanks again for your work.

    Like

      • Thanks Erich…
        Unfortunately the production software runs with a bootloader, so it’s hard (impossible?) to do that. And I have the 128k limited version of CW so that complicates things; even if I do run the ‘debugger located’ version, it has to be severely cut back in order to fit.
        Also the code in question is called a bajillion times, and I suspect only a few times are bad.
        Not looking good for me! 😛
        Cheers

        Like

        • you could add the symbols of the bootloader in the debug session and you should be able to debug it that way with symbols.
          One idea would be (if you can change the code in question) is to check the stack frame and calling PC location: maybe there is a good set of callers, and you could check for it. If it calls from somewhere else: go into a debug routine.
          The best solution would be to use some kind of hardware trace, but that’s the most complicated setup and the hardware needs to support it.

          Like

  14. Hi Erich. A question re nonvolatile storage. We selected Kinetis (on CodeWarrior) as the long-term solution to replace ATmega MCUs some years back. There was always an option for NVM (emulated EE) for us in the family back then, but now it seems that no new variants support this. Also MCUXpresso doesn’t support those earlier models which prevents us using that tool at present.
    We are gearing up to use some other method (IIC FRAM looks promising). This may also give us a path forward using MCUXpresso.
    Do you happen to know why on-board NVM support has been dropped? What do other people do to manage this these days? I’d be interested in any other related comments and suggestions along this track. I’m guessing it’s more to do with manufacturability than demand- I’m sure the need for settings memory still exists!
    Many thanks in advance.

    Like

  15. Hi Erich,

    Love the blogs with lots of useful information for all levels of programmers.
    I have been working recently on a project requiring position indepenedent code for an A/B swappable position bootloader. The project uses an NXP S32k144 chip and some resources were already available for generating position independent code using the eclipse S32DS. NXP posted an example (https://community.nxp.com/docs/DOC-345595) but I could not get it to work for me atm. Even if I could get it to work I would like to know more surrounding the linker and global offset tables (how global variables access it etc.) and the placement of vector interrupt tables.
    I looked through the blog but could not find much on the topic unfortunately (information on the web also has not been very helpful thusfar). Is it an interesting topic for you to write about and help newcomers on this topic?

    Happy blogging.

    Kind regards,
    Sebastiaan

    Like

  16. Hi Erich, just wondering if you have looked at using Rust as an alternative to C ? It seems to have many benefits, but support from manufacturers is still lacking.

    Like

    • Hi Geoff,
      yes, I have looked into it last year, but in my view the situation has not changed: as you mention, there is a lack of tools for it, and I have not found a good way to use it in combination with C/C++. The concept of the language is appealing, but I challenge the real need for it: for me Rust is more a nice-to-have but not something really needed? I see more benefits of having MircoPython on an embedded systems in combination with C/C++.

      Like

  17. Hey Erich. I recently fought for several days on a hard fault issue that I solved with the help of your HardFault PEx component- thank you. This bug was so significant and challenging that I really wanted to share it to help yourself and other people out in future.
    The details are at the end of this thread: https://community.nxp.com/thread/315511
    Best regards.

    Like

  18. Hi Erich,
    Your site’s been an amazing help already – any chance you might try taking on the porting of the power_mode_switch_ca for the RT1052 from the EVK to the Seeed board?

    I’ve made use of your other Seeed examples – really helpful.
    Also tried the low-power port myself, but seems I’ve gotten caught up on something to do w/ the FLASH when it comes to low power modes. (Code runs from FLASH fine, but when updating clocks, FLASH dies despite keeping clock frequency in check).

    I’m a little surprised the demo doesn’t re-locate all their code to RAM… (pretty weird – as that demo SHOULD be working from the EVK’s hyperflash, though I dont have a board to verify)

    Here’s where I am on github: https://github.com/andrewrt/rt1052-power_mode_switch_ca/

    Like

    • I have not played in that area. And because there is the ‘exam season’ right now I doubt I will have a chance in the coming weeks for this anyway.
      Did you create/check the clock settings with the clocks tool? This helped me in the past to find some mistakes too.
      We have modified one of the Seeed boards with a Hyperflash device, but I don’t have access to that board right now, so I cannot check it.

      Like

      • i gotcha, and yes I have used the clock config tool, mainly aiming to keep the FLASH @ or under 133MHz where it’s spec’ed at. Perhaps there are further rules I’m missing.
        Sounds like NXP support has been able to replicate my issue w/ their EVK – shall see what they find!

        Like

  19. Hi Erich,

    I am using KDS Version 3.2.0 and I am working on a project that uses a KE02 (Cortex M0+). I am running into an issue with unaligned memory access (as you know, Cortex M0+ does not support unaligned memory access), which throws a hard fault. The unaligned access is happening for two reasons as far as I can tell: The use of packed structures and having GCC optimize for size (-Os) flag enabled.

    What is happening is that I end up needing to dereference a pointer to a 16 bit member of a packed structure. Depending on the compile, sometimes that member is aligned (placed at an even address) and sometimes that member is unaligned (placed at an odd address).

    If I access the packed structure through the dot (.) and arrow (<-) notation, GCC recognizes the potentially unaligned access and generates the appropriate instructions and all is well. But if I cast a pointer to a member in the packed structure, GCC does not seem to know about this and will try to read a half-word at an unaligned address and hard fault.

    I can work around some of these issues by using the the dot (.) and arrow (<-) notation and other tricks, but the really challenging problem is when the member in the packed structure is a pointer and either the pointer itself or the address it is pointing to is unaligned. I can't seem to find anyway to deference it without causing a hard fault.

    Any tips or tricks on how to deal with this without a big re-write? Even a re-write is challenging because it is not easy to find all the places where unaligned memory access might be happening. Version 9 of GCC added a new warning "-Waddress-of-packed-member" that would be very useful, but upgrading to a newer version of GCC isn't possible in my situation.

    Like

    • I you probably have reasons to use packed structures, but can you avoid this? Exactly for the kind of issues you describe I never us packed structures. If I have a dedicated memory layout e.g. from network packets, then I handle this ‘by hand’ in the send/receive routine.

      Like

      • We have packets coming in over LIN bus from 8-bit devices so we use packed structures to match the incoming data format. The current receiving code is in a shared module that gets compiled for a few other architectures, and those architectures are fine with unaligned memory access, so we haven’t had an issue until now.

        It sounds like a re-write is the way to go. Thanks for the reply!

        Like

        • Yes, I recommend a rewrite. I never use structs to map such data: I always receive the data in an array of bytes and then pack it into the needed structures/etc. Yes, ‘copy-less’ operation is usually what is desired, but for small data packets as they exist in LIN should not be a problem.

          Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.