Microcontrollers

From Wiki at Neela Nurseries
Jump to: navigation, search

2021-07-09 Friday

Notes On Microcontrollers

- neela nurseries keywords template here -
Keywords: two builds west build commands newtmgr


^ Overview

This local wiki page a starting point for general notes on microcontrollers cerca 2020. This local neela wiki article uses the abbreviation "MCU" to mean microcontroller. A few particular MCU families have their own notes pages on this wiki. As of 2022 Q3 these MCU families include:

 


^ ARM microcontrollers

Here information and links regarding low power modes in ARM Cortex M0, M4 and M33 family microcontrollers . . .


^ Manufacturers of Microcontrollers

Manufacturers visited:

Not yet visited:

    • Cypress Semiconductor
    • Renesas of Japan
    • Silabs
    • Dialog
    • Qualcomm

^ NordicSemi

An nRF9160 development kit:

Notes on building, flashing to board, and testing example vRF9160 projects and demos:

^ nRF9160 Getting Started Pages

2021-07-20 Tuesday Searching at NordicSemi.com specifically for example code for the nRF9160:

The most important information for firmware starting works at this link for nRF9160 SDK. Note that there is mention of Zephyr RTOS integration:

Hmm, what we thought was a code bundle, code examples has only pre-built binaries. This developers' forum post spells out in detail what was available -- three demos only -- in 2019. See the replies from Nordic's engineer Oyvind:


2021-07-25
First URL in following list of three URLs may be the best "getting started" page at Nordic. Note also samples and demos page:

^ Hard to locate nRF9160 DK schematic!

A page at Nordicsemi which links to schematics in a larger downloadable file, or so claimed:

Another link seemingly close to the schematic but not getting us there:


^ nRF9160 SDK supported boards

nRF9160 Development Kit (DK) boards:

Smaller dev board from Sparkfun, Thingy:91 . . .


^ nRF9160 Thing Plus by Sparkfun

Some notes on Sparkfun development board named nRF9160 Thing Plus</b>:

How to configure and drive UART on nRF9160:


^ ARM Cortex-M33 CMSIS

ARM Cortex-M33 hardware abstraction layer and CMSIS details here:

Explore and download CMSIS from Github:


^ Sparkfun Thing Plus example code and tools

Working with Sparkfun nRF9160 based Thing Plus, Sparkfun's following page instructs how to install newtmgr:

A couple of useful newtmgr commands include:

  141  newtmgr conn add serial type=serial connstring='dev=/dev/ttyUSB0,baud=1000000'
  142  newtmgr -c serial reset

A helpful CircuitDojo community post on newtmgr:

Installing examples and needed toolchain pieces on Linux hosts:

When attached via USB-C cable, Sparkfun's Thing Plus appears this way in an `lsusb` listing:

   Bus 002 Device 005: ID 10c4:ea60 Silicon Labs CP210x UART Bridge

Back to Nordic example code, the nRF9160 Thing Plus is a supported board there:

Given this tie in with Nordic nRF9160 SDK which appears to be part of Zephyr project example codes, the two builds we're trying to achieve so far from Nordic SDK / Zephyr include:

  west build -b nrf9160dk_nrf9160@1.0.0 ./samples/basic/blinky
  west build -b sparkfun_thing_plus_nrf9160 samples/hello_world
  west build -b circuitdojo_feather_nrf9160ns -p

Not sure in which SDK the second build command worked. That particular board is not found in Nordic's ncs v1.4.1 SDK. The -p option is west's pristine option, essentially causing a rebuild of the project and allowing one to switch board types which the build targets.

Note also if we change working directories into a particular example code we then omit the final argument, the relative path to an example code in the above snippet here. A successful build of 'hello-world' gives these messages:

ted@localhost:~/projects/nordicsemi$ date
Mon 02 Aug 2021 06:33:26 AM PDT 

ted@localhost:~/zephyrproject/zephyr/samples/hello_world$ ls
CMakeLists.txt  prj.conf  README.rst  sample.yaml  src 
ted@localhost:~/zephyrproject/zephyr/samples/hello_world$ west build -b sparkfun_thing_plus_nrf9160
-- west build: generating a build system
Including boilerplate (Zephyr base): /home/ted/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/ted/zephyrproject/zephyr/samples/hello_world
-- Zephyr version: 2.6.99 (/home/ted/zephyrproject/zephyr), build: zephyr-v2.6.0-1460-g17d2e9d084b2
-- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter 
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: sparkfun_thing_plus_nrf9160
-- Cache files will be written to: /home/ted/.cache/zephyr
-- Using toolchain: zephyr 0.12.4 (/opt/zephyr-sdk-0.12.4)
-- Found dtc: /opt/zephyr-sdk-0.12.4/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/ted/zephyrproject/zephyr/boards/arm/sparkfun_thing_plus_nrf9160/sparkfun_thing_plus_nrf9160.dts
sparkfun_thing_plus_nrf9160.dts.pre.tmp:58.42-70.3: Warning (unique_unit_address_if_enabled): /soc/peripheral@50000000/flash-controller@39000: duplicate unit-address (also used in node /soc/peripheral@50000000/kmu@39000)
sparkfun_thing_plus_nrf9160.dts.pre.tmp:310.19-316.3: Warning (unique_unit_address_if_enabled): /soc/peripheral@50000000/clock@5000: duplicate unit-address (also used in node /soc/peripheral@50000000/power@5000)
-- Generated zephyr.dts: /home/ted/zephyrproject/zephyr/samples/hello_world/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/ted/zephyrproject/zephyr/samples/hello_world/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/ted/zephyrproject/zephyr/samples/hello_world/build/zephyr/include/generated/device_extern.h
Parsing /home/ted/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/ted/zephyrproject/zephyr/boards/arm/sparkfun_thing_plus_nrf9160/sparkfun_thing_plus_nrf9160_defconfig'
Merged configuration '/home/ted/zephyrproject/zephyr/samples/hello_world/prj.conf'
Configuration saved to '/home/ted/zephyrproject/zephyr/samples/hello_world/build/zephyr/.config'
Kconfig header saved to '/home/ted/zephyrproject/zephyr/samples/hello_world/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- The ASM compiler identification is GNU 
-- Found assembler: /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ted/zephyrproject/zephyr/samples/hello_world/build
-- west build: building application
[1/145] Preparing syscall dependency handling

[138/145] Linking C executable zephyr/zephyr_prebuilt.elf

[145/145] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       16492 B         1 MB      1.57%
            SRAM:        4072 B        64 KB      6.21%
        IDT_LIST:          0 GB         2 KB      0.00%
ted@localhost:~/zephyrproject/zephyr/samples/hello_world$


^ Zephyr docs on Sparkfun nRF9160 Thing Plus


^ Nordic ncs - nRF Connect Software development kit

Looking further for Sparkfun's named or implied example code projects for Sparkfun's nRF9160 Thing Plus, finding that ncs SDK is elusive. There is mention of this SDK in Sparkfun's "nRF9160 Thing Plus Hookup Guide". One Devzone member Raj also mentions it in response to a post of IIoT team. But it's not obvious from where to download ncs from any of the following pages:

'Ah' moment! Here is a URL to the page and anchor point of NordicSemi, of which Devzone engineer Marte was speaking:

Also important, and more insight into nRF SDK or Software Development Kit, following links include intro, west manifest, and ncs release notes:

Finally, a git repository and command to obtain Software Development Kit 'ncs', in this case version 1.4.1:

Following instruction from:

*  https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.1/nrf/gs_installing.html
*  https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.1/nrf/gs_installing.html#id1

Command to indirectly clone one or more repositories under the git v1.4.1 ncs repository a west meta-tool project space. Wording the description this way because the following command pulls multiple things down from github to an end user's current directory but none of these are named 'v1.4.1':

$ west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.4.1


Among those code repos pulled by west the Zephyr RTOS project instance here is at commit hash:

ted@localhost:~/projects/embedded/ncs/v1.4.1/zephyr$ git log
commit e34b2f477e1adc26b66690171508bfa102eb8538 (HEAD, tag: v2.4.0-ncs2-rc1, tag: v2.4.0-ncs2, manifest-rev)
Author: Joakim Andersson <joakim.andersson@nordicsemi.no>
Date:   Fri Nov 20 14:44:03 2020 +0100

    [nrf noup] Bluetoooth: Add experimental for non-qualified options
    
    Zephyr controller does not yet have a qualification for this release.
    Bluetooth Mesh does not yet have a qualification for this release.
    
    Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>


Within ncs v1.4.1 the basic blinky demo may be compiled for Sparkfun's nRF9160 Thing Plus board:

ted@localhost:~/projects/embedded/ncs/v1.4.1/zephyr/samples/basic/blinky$ west build -b circuitdojo_feather_nrf9160ns

And per Sparkfun's Thing Plus Hookup guide this dev board may be flashed with:

 newtmgr -c serial image upload build/zephyr/app_update.bin


^ Build comparison across hosts

Something strange afoot: building Sparkfun Thing Plus, Zephyr blinky demo, produces differing output files across two hosts. Specifically attempts to build blinky example code per Jared Wolff's guide produce different sets of executables. The latter on a native Linux host produces among many file a file named app_update.bin. Building same project, in same commit of Zephyr project as downloaded by `west` in ncs v1.4.1 does not product nor mention any app_update.bin.

Build messages from a native Ubuntu Linux host and a virtual machine running Linux within host OS Windows linked here:

*  Zephyr build on native Ubuntu host
*  Zephyr build on VirtualBox VM

Found a local change to blink example prj.conf file:

Code excerpt x:

CONFIG_GPIO=y

## 2021-08-02 adding stanza per https://learn.sparkfun.com/tutorials/nrf9160-thing-plus-hookup-guide#example---blinky:
CONFIG_BOOTLOADER_MCUBOOT=y

Device tree related file for Sparkfun, CircuitDojo nRF9160 Thing Plus board. We will likely need to understand and adapt this file going forward with works involving nRF9160 SiP:

/*
 * Copyright (c) 2018-2020 Nordic Semiconductor ASA
 * Copyright (c) 2020 Circuit Dojo LLC
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/dts-v1/;
#include <nordic/nrf9160_sica.dtsi>
#include "circuitdojo_feather_nrf9160_common.dts"

/ {
        chosen {
                zephyr,sram = &sram0_s;
                zephyr,flash = &flash0;
                zephyr,code-partition = &slot0_partition;
                zephyr,sram-secure-partition = &sram0_s;
                zephyr,sram-non-secure-partition = &sram0_ns;
        };
};

More on Device Tree Source files in local Neela page on DTS files, starting with examination of Zephyr example code.


^ Microcontroller Qualities and Considerations

Low power benchmark testing:

Out of Order Execution:


^ References

Util nrfjprog suppposedly here:

Using Docker build an ncs project ( if we can find nsc software development kit! - TMH ):


- - - top of page - - -