Code Monkey home page Code Monkey logo

flashalgo's Introduction

FlashAlgo

Framework for building Arm "FLM" style flash programming algorithms.

Other options

Before you consider adding a flash algo here, you might wish to check if an open source flash algo already exists for your device or a similar device. Many of the FLM flash algos included in CMSIS Device Family Packs (DFPs) come with source code. For instance, the Keil DFPs include sources.

You can download a DFP for your device from the official CMSIS-Pack list: by pack or by part number.

DFPs extract as zips (change the extension). For the DFPs created by Keil, .FLM algos and code are under ./CMSIS/Flash/. Other vendors may have algos in a different folder, and may or may not include source.

Development Setup

Skip any step where a compatible tool already exists

  1. Install Python 3.6 or later and make sure it's added to path
  2. Install Git and make sure it's added to path
  3. Install a supported toolchain:
    1. GNU Arm Embedded
    2. Keil MDK-ARM
  4. Install GNU Make.
$ git clone https://github.com/mbedmicro/FlashAlgo
$ python3 -mvenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

Develop

GCC with Make

  1. Update tools and generate project files. This should be done everytime you pull new changes
$ progen build -t make_gcc_arm

Add the project name(s) to the command if you only want to build a limited set of projects. You can list available projects with progen list -f projects.yaml projects.

MDK

$ progen generate -t uvision
$ tools\launch_uvision.bat

Now open the project file for the desired target in .\projectfiles\uvision\<target>\

To change the RAM base address to something other than the default value of 0x20000000, add the argument --blob_start <hex-ram-address> in "Projects ❱ Options ❱ User ❱ After Build/Rebuild section of the µVision project.

Adding a new project

For adding new targets start from template and use these docs...

Contributions

We welcome contributions! Please see the contribution guidelines for detailed requirements. In order to foster a healthy and safe community, all contributors are expected to follow the code of conduct.

To report bugs, please create an issue in the GitHub project.

flashalgo's People

Contributors

0xc0170 avatar bentcooke avatar c1728p9 avatar carlosperate avatar driftregion avatar flit avatar jnthbdn avatar kaizen8501 avatar lindvalla avatar linlingao avatar mfiore02 avatar microbit-carlos avatar mmahadevan108 avatar sarahmarshy avatar sg- avatar shareefj avatar stevew817 avatar toyowata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flashalgo's Issues

Document 'Adding new Targets'

There is a docs directory with a doxyfile. This can be built but output is ignored as part of this repo. Where to host the output? If not hosted, then update current readme to alert contributors of needing doxygen to build docs or just read the template (example) project.

GCC support

Currently GCC linker file doesnt create output that is compatible with armcc tools. The c_blob and py_blobs rely on armcc output formats. For GCC support the following is needed:

  1. makefile in pgen extended to support post build user commands
  2. *.ld modified to mimic the same memory layout as *.sct
  3. possible update to scripts/generate_blobs.py if gcc output and keywords are not the same as armcc.

Release script

Building all projects is with pgen.

>pgen build -f records/projects.yaml -t uvision

There should be a script that takes all the c_blobs and py_blobs and moves them to a release folder which is versioned as part of this repo.

`make_gcc_arm` tool does not generate the embeddable blobs

Generating and building uvision projects also creates the .c and .py files with the blobs embedded, but this does not happen with make_gcc_arm.

I don't have IAR, so I cannot confirm if these files are generated with that project type or not.

flash_algo.py problem

Hello. I am trying to run a flash_algo.py file.
I need to create an algo file for stm32h7. However, I am getting the error.
What could be the reason for this?

(venv) root@Note:/mnt/d/pyTest# python3 flash_algo.py STM32H7xx.FLM c_blob.tmpl out.c
Traceback (most recent call last):
  File "flash_algo.py", line 349, in <module>
    main()
  File "flash_algo.py", line 45, in main
    algo.process_template(args.template, args.output)
  File "flash_algo.py", line 158, in process_template
    target_text = template.render(data_dict)
  File "/mnt/d/pyTest/venv/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/mnt/d/pyTest/venv/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 41, in top-level template code
jinja2.exceptions.UndefinedError: 'header_size' is undefined

Update Flash Algo for ARMC6 compiler

The project generator has been updated to include support for Cortex-M33 targets. The uvision project template files need to be updated for ARM compiler 6 projects. The current template causes for following build error:


ArmClang.exe: error: unsupported option '--gnu', did you mean '-fgnu'?


ST L151CC algorithm issues

I've attempted to write interface firmware for a new mbed platform. The interface processor is a MK20DX128VFM and the target processor is a STM32L151CC. I've linked to my DAPLink and FlashAlgo repositories.

Currently the drag-n-drop program of the device appears successful. After programming is finished there is no fail.txt file in the USB drive. The target processor does not appear to execute, however. When connecting with a debugger, I see the following message each time I try to continue/run the application:

(gdb) c
Continuing.
stm32l1.cpu -- clearing lockup after double fault

However, if I load the same binary using the debugger or an external programmer (bypassing the interface processor), the device functions perfectly. This fact leads me to believe that the issue is the flash algorithm itself or the state the processor is in after the flash algorithm runs.

The flash algorithm code was taken from an example flash algorithm included with uVision and updated. The original code can be found at C:\Keil_v5\ARM\Flash\STM32L15x.

I have read out the contents of flash via the debugger and it looks the same (MD5 checksums matched) as the original binary.

I am aware that a double fault is usually caused by an invalid vector table, but as far as I can tell the vector table in the application is fine.

I've attached the test binary I've been using. When programmed with the debugger or an external programmer, it works great. When programmed by the interface firmware & flash algorithm, it doesn't work at all. I added the .txt to the binary name so GitHub would let me attach it.

I appreciate any help or advice on this issue.
blink.bin.txt

uVision project cannot build

My env:

Python 2.7.12
progen 0.9.2
Keil MDK 5.17
ARM Compiler 5.06 update 1 (build 61)

As the README.md says, execute cmd:

$ progen generate -t uvision

then open project projectfiles\uvision\lpc4088\lpc4088.uvproj, try to build the target, log shows:

Build target 'lpc4088'

then MDK UV4.EXE collapses.

anything wrong?

Use DevDscr when generating prog_blobs

The DevDscr has details about the target and could be extended to have information about where the algo is placed in RAM (start, buffer, SP,etc..) These are currently hardcoded in the generate script and also the templates. Should be dynamically generated by the flash algo projects being they're aware of the target on which they run

FTMRE Support / MKE04Z - MKE06Z

There is no support for FTMRE flash module. Could you please either add the support or add the flash blob file for the mentioned MCU's? Thank you.

pyocd raises FlashAlgoException on FlashAlgo FLM

Background

I have a Keil pack that is missing a flash memory region which I'd like to manipulate via pyocd.

Pack

https://developer.arm.com/embedded/cmsis/cmsis-packs/devices/NXP/S32K142UAxxxLLx
Keil.S32_SDK_DFP.1.5.0.pack
Keil.S32_SDK_DFP.pdsc

Memory regions

  1. 0x00000000-0x00040000 "Program / code flash" (pack contains .FLM, usable with pyocd)
  2. 0x10000000-0x1000FFFF "FlexNVM / code flash" (no .FLM)

relevant section of .pdsc:

        <!-- ******************************  Device 'S32K142'  ****************************** -->
        <device Dname="S32K142">
          <book name="doc/S32SDK_S32K142_UserManual.pdf" title="S32SDK User Manual"/>

          <compile header="platform/devices/device_registers.h"/> <!-- generates warning in PackCheck because name is not CMSIS conform -->
          <compile define="CPU_S32K142"/>
          <debug  svd="platform/devices/S32K142/S32K142.svd"/>
          <memory id="IROM1"                                     start="0x00000000" size="0x00040000" default="1" startup="1"/>
          <algorithm name="CMSIS/Flash/S32K142_P256_2KB_SEC.FLM" start="0x00000000" size="0x00040000" default="1"/>
        <!-- variants... -->
        </device>

Problem encountered

I've found and read the CMSIS-Pack-Spec Flash Algorithm documentation: https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/flashAlgorithm.html

I've started by reproducing the existing .FLM for memory region 0x0000000-0x00040000. A patch is here:
driftregion@c646334

Using this patch to pyocd flash ... , I find the following error:

pyocd.target.pack.flash_algo.FlashAlgoException: RW section does not follow RO section

This looks linker-related, but I'm not sure where to start.

I've attached the original .FLM (S32K142_P256_2KB_SEC.FLM.bak) and the .FLM produced by my patch (S32K142_P256_2KB_SEC.FLM) as a zip file:
S32K142_P256_2KB_SEC.zip

FlashAlgo:project_generator question

  • is it possible for a project in projects.yaml to output multiple .elf/.FLM files? This target device has two non-contiguous flash regions. If I understand correctly, each region needs its own .FLM

Upstreaming question

  • If this works and results in a usable .FLM, is there an established way to share community-extended .pack files?
  • Alternately (preferably?), is it probable that NXP would update their .pack?

Related:
pyocd/cmsis-pack-manager#122 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.