simap / pixelblaze_output_expander

24 stars 4 forks source link

Programming and Compiling #4

Closed cinderblock closed 4 years ago

cinderblock commented 4 years ago

Hello again.

We have created our first board that replicates your board's features (and adds RS-485, optional half-duplex comms, and GPIO inputs). I am trying to program the board.

It is not clear to me which IDE you are using or how to setup the environment properly. It looks like you might be using some of STM's proprietary tools. I wonder if you could make a quick list of how you program the boards.

On a related note, have you considered using more open tools? I'm thinking something like Platform IO, for instance.

In trying to use common tools that I'm more familiar with, I've got a Segger J-link connected to the MCU. I can connect and communicate with the chip over SWD and it reported "success" when I ran loadbin expanderboard2.bin, 0. However it's not clear to me if that was the correct way to load the flash. I'm just guessing that the bin should be programmed to flash address 0. Any thoughts on this would be greatly appreciated.

I'll have an extra expander to test and compare against on Tuesday but was hoping to get to something working, or at least a better understanding, before then.

Thanks.

simap commented 4 years ago

Hello! Yes, I used STM's tools. The expanderboard2.ioc file can be used to generate a project with the older STM32CubeMX tool, or in the same tool integrated into Eclipse called STM32CubeIDE.

Once the project and build files are generated, the source files can be dropped in (or otherwise ensure they aren't overwritten by the tool).

If I was doing it from a GH clone, I'd probably do this:

  1. Install STM32 Cube IDE
  2. Make a new project with the target processor.
  3. Replace the template source files and ioc file with that from the GH project.

That would get you a working Eclipse that could flash and debug using SL-link, and should certainly work with Segger J-Link as well.

For programming .bin files, yes, basically you can flash the .bin file to the flash location. I again use ST's tools and an $2 ST-Link clone to do the work. You can see my setup here:

https://www.youtube.com/watch?v=mRDbnhS1aow

I have nothing against PlatformIO, but ST's cube tool is very helpful for setting up all of the clocks and peripheral initialization code. Sometimes I have to rewrite it, but it's usually a good start.

cinderblock commented 4 years ago

+1 for the fancy proprietary code generators when they work well. I played with Cypress's FPGA/MCU configuration tools in the past. Not sure I could have done it without the GUI.

Is the information in the ioc file already included in the source? Should I be able to just use the source and my own build/flashing to make it work? Just curious.

I'll give the STM32 Cube IDE a try. Didn't realize it was based on Eclipse. At least it has that going for it. These days I just want to use VS Code for everything though.

I still don't understand the whole programmer/debugger ecosystem. I have a J-Link but apparently that hardware doesn't cost enough to handle .elf and they want an extra subscription to turn that feature on for my hardware. Bleh.

I'm used to the AVR world with avrdude and knowing the flash/FUSE layout like the back of my hand. I still haven't used ARM enough I guess. I'll take a look at the clone.

PS, Nice programmer/tester! I did a similar thing for a project. It also gave each one a unique serial number by generating .hex files on the fly and only recorded it in the database once it was programmed correctly, all in a nice NodeWeb GUI. :)

PPS, have you seen these? I use them for all my board programming these days. Even some for debugging if needed. https://www.tag-connect.com/product/tc2030-idc-nl

cinderblock commented 4 years ago

Sorry to bump,

I've got a ST-Link programmer working with STM32CubeProg and am able to load the published .elf file onto the chip. However when I send it serial data, the output LED does not turn on. I have tried this with multiple of the boards I have. I'm not seeing why this should work.

My bet is that there are some user configuration bits that need to be set properly but looking through what I've found, I haven't seen anything that seems like it.

Any thoughts would be greatly appreciated.

simap commented 4 years ago

There aren't any special config bits I set. I leave those all default. I'd try to get the IDE up and running, and then you can set breakpoints and see what it sees (though the buffer won't get more data while you are in a breakpoint, and if it did it would overflow quickly).

There's a few variables helpful for seeing problems.

https://github.com/simap/pixelblaze_output_expander/blob/master/firmware/Core/Src/app.c#L98

It turns on the LED anytime it sees it's address, so maybe your address is wrong (or you aren't shorting the GPIO to get address 0). Even if the CRC is bad, the led will show something.

So either the board isn't seeing uart frames (make sure its 2Mbaud), or its not seeing the magic header, or its not seeing a frame with it's address. You can set breakpoints at various locations in the code to see if it gets that far, and inspect any variables read previously.

cinderblock commented 4 years ago

Wow! I knew it was something stupid simple! Thanks so much for your help.

Turns out my board defaults to 0b111 address while yours is 0b000!

For those curious, I used this programmer with STM32CubeProgrammer and the .elf file in this repo to program by STM32F103C8 via SWD (4-pins total) without a hitch, including updating firmware on the programmer.

simap commented 4 years ago

@cinderblock Hey, btw what are you using to send data? There's a lot of folks interested in using these boards with non-Pixelblaze stuff. Are you sending from a Pi or something or from another micro e.g. using code from the Arduino driver? Any code/insights you could share with folks?

cinderblock commented 4 years ago

For testing I've just hacked an RS-485 transceiver onto a pixelblaze.

High level, the piece will have 3 identical (from an electrical perspective) sculptures. Each sculpture needs 3~4 output expanders to drive the LEDS we want to drive where we want to drive them. So each sculpture will be on a single RS-485 bus carrying a single serial stream of pixel data.

As for driving each sculpture's differential serial line, we have two options:

Option A: Lines run to central cabinet with a Windows/Linux machine running our pattern generation software, connected with a USB to RS-485 transceiver.

Option B: (If RS-485 runs are too long for baud rate) Lines run to Raspberry Pi based controller at the base of each sculpture and treat/run those as ArtNet/sACN to RS-485 converters.

So, we'll likely be writing our own output drivers. Our main pattern generation software is all in C++ (I think the plan is to release it eventually). I've also written a driver for JavaScript (running from Node.js).

I'm more than happy to share what I have. Where are these discussions?

simap commented 4 years ago

A lot in this thread: https://forum.electromage.com/t/new-8x-ws2812-apa102-driver-board/285

and popped up again here: https://forum.electromage.com/t/pixelblaze-output-expander-raspberry-pi/495/3

cinderblock commented 4 years ago

Thanks for the links. I don't see what I can contribute to those conversations specifically right now.

I hadn't found these forums. You might consider adding a link to the README ;)