AP_Periph 1.0.0 stable released

Oh the red blue sequence? Yeah I like it too. I did enable the baro sensor in MP via UAVCAN

I was just wanting to make sure AP will actually use it. Everything I have read expects an external baro sensor to be on the I2C bus

Hi,
AP_Periph is great work, I’m digging in. I am a UAVCAN and CAN bus advocate and am working up the AP_Periph build learning curve. I’ve managed to successfully build and load f103-GPS and f303-GPS examples on Ubuntu 18.04, starting with bootloaders flashed to the processors via ST-Link and then using UAVCAN GUI to update the as-built firmware binary.

Below is my UAVCAN test setup. I’m running with UAVCAN GUI plugged in to the FTDI via SLCAN adapater. My node is either an STM32F103CB modified bluepill or an STM303CC blackpill board with CAN adapter breakout boards. Based on schematics (https://github.com/mRoboticsIO/CANNode/tree/master/Schematic) I believe my nodes are breadboard equivalents of the F1 and F3 mRo CAN Node variants.

I’m interested in building and documenting minimum viable F103 and F303 libcanard node examples that works with the AP_Periph bootloader. I’ve had success with this example (https://github.com/skyyuzhang/UAVCAN_NODE_FreeRTOS) as bare metal loads no bootloader. I also have STM32 Arduino variations of this demo built and tested here (https://github.com/geosmall/UAVCAN-for-STM32-Arduino).

I am now trying to understand the changes needed to get it to work with the AP_Periph bootloader. I’ve changed the linker script to relocate the flash and ram starts, and eliminated the SCV->VTOR startup code so as to keep bootloader VTOR value. The GUI lets me upload the binary just fine but the node does not start up and drops back into MAINTENANCE mode.

I can see that the bootloader does some firmware signature checks (https://github.com/ArduPilot/ardupilot/blob/141099078ce11f5ee1b78debb1ec52222c7fafc7/Tools/AP_Bootloader/AP_Bootloader.cpp#L89 and https://github.com/ArduPilot/ardupilot/blob/141099078ce11f5ee1b78debb1ec52222c7fafc7/Tools/AP_Bootloader/can.cpp#L564) so I have a bit more learning to do.

Perhaps there might also be some WAF magic in signing of the binary?

Is there any guiding info on how to create and sign a binary to work with AP_Periph bootloader? I’m close but am missing a few key details. I believe that open source AP_Periph bootloader together with simple, well documented ‘hello world’ build could greatly aid in adoption of UAVCAN.

Thanks!
George

thanks for sharing!

Only the AP_Periph code itself in Tools/AP_Periph, but here is a summary of what it needs:

Once that passes the firmware will run, but before it runs the bootloader setups up the IWDG (independent watchdog) so that if the firmware crashes the board resets. The bootloader can detect this reset and decide if it should re-run or stay in bootloader for user to try loading a new fw. It decides that based on a RTC register here:
https://github.com/ardupilot/ardupilot/blob/pr-imu-adis16470/Tools/AP_Bootloader/AP_Bootloader.cpp#L98
the app should set the RTC register after 30s of running, to tell the bootloader in the case of a watchdog that it had been running happily for 30s, in which case the bootloader will run it again. If the app had been running for less than 30s then the bootloader will stay in maintenance mode.
When in maintainence mode the bootloaders set the vendor_specific code visibile in the uavcan_gui to tell the user why it is in maintainence. The reasons are listed here:
https://github.com/ardupilot/ardupilot/blob/pr-imu-adis16470/Tools/AP_Bootloader/can.cpp#L82
and are:
enum {
FAIL_REASON_NO_APP_SIG = 10,
FAIL_REASON_BAD_LENGTH = 11,
FAIL_REASON_BAD_BOARD_ID = 12,
FAIL_REASON_BAD_CRC = 13,
FAIL_REASON_IN_UPDATE = 14,
FAIL_REASON_WATCHDOG = 15,
};
that gives you a way to know why your app is not working.
Good luck with the project, and keep us informed on how you do!
Cheers, Tridge

oh, I should have also mentioned that as IWDG is running the app must “pat the dog” frequently to prevent a watchdog reset.
See this function stm32_watchdog_pat():
https://github.com/ardupilot/ardupilot/blob/pr-imu-adis16470/libraries/AP_HAL_ChibiOS/hwdef/common/watchdog.c#L75
if you stop patting for 2s then you’ll get a MCU reset.

Hi George,

I originally tried to use the Blue Pill boards to prototype, be aware that even this board pictured has a pullup resistor R6 to 3.3v on PA12 for use with the USB functionally. That may need to be removed to properly utilize CAN.

Sincerely,
Phil

Thanks Phil,

Yes I am aware of the AP-12 pull-up (4.7K on the ones I have checked). It would probably be best for me to remove that resistor, but it has not caused any trouble to date in a year or so of testing on F103 and F303 variants running the CAN bus at 1MHz. But good to keep it in mind, thanks for the info.

George

@tridge.

I have a question for you, the baro sensor in the GPS antenna gets listed as absolute pressure2 in the mavlink explorer.

Do you know if that sensor is being used as primary or is it secondary? It looks like I can go into the parameter settings and change it to use baro sensor 2, but is that actually the can GPS baro sensor?

That makes sense

The simple way to remember is that the CAN baro is always the first sensor if enabled. The assumption is that if you’ve bothered to get a CAN baro then you want to use it, so it defaults to the first one.

1 Like

One more CAN question if you don’t mind. Both the NEO V2 pro and the Here2 have safety switches. In in 4.0+ uavcan supports a safety switch function. Is this something I can configure or does it just work?

Thanks

In the 4.0 stable releases it should “just work” as long as UAVCAN is enabled.

@Matt_C I just tested a f103 mRo node with the following:

  • a lightware serial rangefinder at 115200, using the f103-Rangefinder firmware, testing both stable and latest. All worked

  • a drotek F9P GPS with f103-GPS firmware, both stable and latest. Both firmwares worked.

yes, sorry about that. I intend to create a “universal” firmware for f303 that will have enable parameters for all the different functions. I just haven’t done that yet.

Using the uavcan_gui_tool can you please send me screen shots of the full parameter list for the nodes when trying f103-rangefinder or f103-gps. Also, please start the bus monitor under Tools menu and see what messages the f103 nodes is producing.
For comparison, here is what I see for f103-GPS:


and this is bus monitor with a F9P (without corrections being injected)

I have highlighted the Fix2 message, which is the essential one for RTK

I’ve now created a PR for a f303-Universal firmware that includes all the features with params to enable/disable

1 Like

the f303-Universal firmware is now in download area:
https://firmware.ardupilot.org/AP_Periph/latest/f303-Universal/

DJI’s A3 GPS units have a LPC1549 MCU. 256KB flash, Cortex-M3.
|There’s a M8N on UART, QMC5883 clone on I2C and RGB leds on three GPIOs.

Can it be converted ? I’m worrying abouth the LEDs :slight_smile:

It works! I now have a “Hello World” FreeRTOS based AP_Periph node up and running. I used F103-GPS bootloader (APJ_BOARD_ID 1000) loaded on a bluepill F103C8 board plus CAN adapter as my target node hardware.

Steps:

Working demo project is located in this repo under AP_Perph branch: GitHub - geosmall/UAVCAN_NODE_FreeRTOS at AP_Periph

Screen cap below of the working node in UAVCAN GUI, showing “mgeo.node.demo” at Node ID 10 and bootloader at Node ID 117.

Next steps will be to come up with a working Arduino AP_Periph demo using this core GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino. If all goes well we should be able to generate a range of AP_Periph bootloader compatible UAVCAN nodes via Arduino IDE for a range of STM32 based targets.

1 Like

Would it be possible to have a RM3100 working on AC 3.6.11 trough APPeriph 1.0.0 ?

I am asking because we use a custom version of 3.6.11 and can’t migrate to 4.0 at the moment but would like very much to test the RM3100.

The RM3100 connected via SPI on AP_Periph / mRo CANNode works great for us and works great with AC 3.6.11, if the proper params are set. Let me know if you need any help.

Great!!! Yes i think i need some help. I’ll go buy the needed hardware for AP_Periph and will come back for some help.
Once connected trough AP_Periph, the RM3100 used as a UAVCAN compass? I mean do i have to enable UAVCAN compass driver in the bitmask for the compas?
In the meantime the board arrives, any how too to where to start would be great!!!

Thanks

Yes, it appears as a generic UAVCAN Compass.

Have you already purchased the CANNode or RM3100? If not we have a new board that I can see if it ready to ship. It includes a RM3100, DPS310, triColor Status LED and Safety switch already connected to a CANNode running AP_Periph. https://store.mrobotics.io/ProductDetails.asp?ProductCode=MRO10025

Your solution is plug and play?
Is there a place in Europe where i can purchase it?
DSP310 is a new barometer? If so, does it work good?