Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AT32 chips #8752

Merged
merged 5 commits into from
Mar 23, 2023
Merged

Conversation

DusKing1
Copy link
Contributor

@DusKing1 DusKing1 commented Jan 31, 2023

This PR introduces support for AT32F435/7 chip, including the BSP lib, src code changes, cmake scripts, new at32 targets, some bug fixes, etc. The 5 commits are:

  1. Add AT32 BSP LIB
  2. Add support for AT32
  3. Added LSM6DSXX IMU drivers, including LSM6DSO, LSM6DS3TR-C, LSM6DSL. The twothree NeutronRC AT32 targets submitted in 5 need this IMU driver
  4. Fixed the flash index overflow bug
  5. Added twothree NEUTRONRCF435 targets

We understand the complexity of this PR, so we are willing to further split this PR according to the guidance of the inav team.

Primary credit to @tcdddd , also thanks to my flightng team colleagues: @shanggl, @pdwdw and NT.JIA.

-- Chinese version --

本PR引入了对AT32F435/7芯片的支持,包括BSP,src代码,cmake脚本,AT32飞控目标添加,部分bug修复等。5条commits的具体内容为:

  1. 添加AT32 BSP LIB
  2. 添加对于AT32的支持
  3. 添加了LSM6DSXX陀螺仪驱动,包括LSM6DSO、LSM6DS3TR-C、LSM6DSL。5中提交的两个三个新目标使用该IMU
  4. 修复了flash index 溢出的错误
  5. 添加了两个三个NEUTRONRCF435目标

我们理解该PR的复杂性,所以我们愿意根据INAV团队的指导对该PR进行进一步拆分。

首要致敬 @tcdddd ,同时还要感谢flightng团队的同事们:@shanggl@pdwdw以及NT.JIA。

@@ -49,4 +49,11 @@ bool i2cBusReadRegister(const busDevice_t * dev, uint8_t reg, uint8_t * data)
const bool allowRawAccess = (dev->flags & DEVFLAGS_USE_RAW_REGISTERS);
return i2cRead(dev->busdev.i2c.i2cBus, dev->busdev.i2c.address, reg, 1, data, allowRawAccess);
}
bool i2cBusBusy(const busDevice_t *dev, bool *error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking existing targets.

You can either turn this function into a macro that translate to false (better code footprint for other targets) or mark the parameters with UNUSED()

Copy link
Contributor

@shanggl shanggl Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yelp ,i2cBusBusy function 's unused parm "dev“ and "error " may cause a unused param warning in my localhost , i will fix this today

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github builds enable warnings as errors. It would save time if you could build like that locally as well.

Try running cmake -DWARNINGS_AS_ERRORS=ON and running make release to build all targets as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github builds enable warnings as errors. It would save time if you could build like that locally as well.

Try running cmake -DWARNINGS_AS_ERRORS=ON and running make release to build all targets as well.

All warnings has been fix yesterday , and tested the STM32F411 F405 F722 and H743 , all targets 0 errors 0 warnings

src/main/drivers/dma.h Outdated Show resolved Hide resolved
@mmosca
Copy link
Collaborator

mmosca commented Feb 1, 2023

I see there are lots of comments in Chinese in these commits, many also are tagged with TODO.

Instead of tagging every file, I will just give the overall suggestion of keeping the code/comments in English.

English is not my native language either, but it is the language used in the code and documentation.

While google translate can deal with the translation fairly well, it adds friction. Remember, this is an open source project with a fairly international list of contributors. People from other backgrounds may eventually have to make changes in the code and keeping it in a single language is probably a good call.

@erstec
Copy link
Collaborator

erstec commented Feb 1, 2023

@shanggl
After tests on real AT32 FC there are few things I noticed and want to share (all for NEUTRONRCF435AIO target):

  • Gyro orientation for BMI270 should be CW180_DEG
  • ADC readings is wrong, both Voltage and Current (I don't know why, have no time to dig)
  • LED strip not working (as I see it causes some conflicts with UART3 TX)
  • Rename UART8 -> UART5, as on FC pads are R5 and T5 (at least on one I have)

Configurator build able to flash this MCU here https://drive.google.com/file/d/1C9BsJGfIvqz2aFkYQ0daZpAjpUk06EcZ/view?usp=sharing (if someone need it)

P.S. Neutronrc F435 FC are mounted on one of my quad and I can test and check all (if you need).

@DusKing1
Copy link
Contributor Author

DusKing1 commented Feb 1, 2023

@shanggl After tests on real AT32 FC there are few things I noticed and want to share (all for NEUTRONRCF435AIO target):

  • Gyro orientation for BMI270 should be CW180_DEG
  • ADC readings is wrong, both Voltage and Current (I don't know why, have no time to dig)
  • LED strip not working (as I see it causes some conflicts with UART3 TX)
  • Rename UART8 -> UART5, as on FC pads are R5 and T5 (at least on one I have)

Configurator build able to flash this MCU here https://drive.google.com/file/d/1C9BsJGfIvqz2aFkYQ0daZpAjpUk06EcZ/view?usp=sharing (if someone need it)

P.S. Neutronrc F435 FC are mounted on one of my quad and I can test and check all (if you need).

  1. Thanks we will fix it, and we have decided to rename it to NEUTRONRCF435SE
  2. ADC issue is a known bug, and there are some other known bugs, @shanggl will share the detail of the technique dilemmas we have met with you and let's find out the solution for them
  3. @shanggl
  4. Typo, will fix it immediately

@erstec Can you PR the code for the configurator at the same time?

@mmosca We will translate all Chinese comments into English in days.

@erstec
Copy link
Collaborator

erstec commented Feb 1, 2023

@shanggl After tests on real AT32 FC there are few things I noticed and want to share (all for NEUTRONRCF435AIO target):

  • Gyro orientation for BMI270 should be CW180_DEG
  • ADC readings is wrong, both Voltage and Current (I don't know why, have no time to dig)
  • LED strip not working (as I see it causes some conflicts with UART3 TX)
  • Rename UART8 -> UART5, as on FC pads are R5 and T5 (at least on one I have)

Configurator build able to flash this MCU here https://drive.google.com/file/d/1C9BsJGfIvqz2aFkYQ0daZpAjpUk06EcZ/view?usp=sharing (if someone need it)
P.S. Neutronrc F435 FC are mounted on one of my quad and I can test and check all (if you need).

  1. Thanks we will fix it, and we have decided to rename it to NEUTRONRCF435SE
  2. ADC issue is a known bug, and there are some other known bugs, @shanggl will share the detail of the technique dilemmas we have met with you and let's find out the solution for them
  3. @shanggl
  4. Typo, will fix it immediately

@erstec Can you PR the code for the configurator at the same time?

@mmosca We will translate all Chinese comments into English in days.

@DusKing1 sure, just let me back home to my main PC )

@shanggl
Copy link
Contributor

shanggl commented Feb 2, 2023

@shanggl After tests on real AT32 FC there are few things I noticed and want to share (all for NEUTRONRCF435AIO target):

  • Gyro orientation for BMI270 should be CW180_DEG
  • ADC readings is wrong, both Voltage and Current (I don't know why, have no time to dig)
  • LED strip not working (as I see it causes some conflicts with UART3 TX)
  • Rename UART8 -> UART5, as on FC pads are R5 and T5 (at least on one I have)

Configurator build able to flash this MCU here https://drive.google.com/file/d/1C9BsJGfIvqz2aFkYQ0daZpAjpUk06EcZ/view?usp=sharing (if someone need it)

P.S. Neutronrc F435 FC are mounted on one of my quad and I can test and check all (if you need).

@erstec thks a lot

  1. gyro orientation has been fix by @DusKing1
  2. adc still has bugs ,i'm working on , the main reason is the Vref is not used to calibate the adc analog value of Voltage and Current ,this will be fix in next pr .
  3. LED strip not working, i think is wrong value of the MAX_PWM_OUTPUT_PORTS , i will debug and fix this in next pr .
  4. UART8 is a mis typeing ,has been fixed by @DusKing1

the compile warning errors has been fixed yesterday

@mmosca
Copy link
Collaborator

mmosca commented Feb 2, 2023 via email

@shanggl
Copy link
Contributor

shanggl commented Feb 3, 2023

I don’t think it is a good idea to keep comments in both languages. Keep it simple. Duplicate comments will eventually get out of sync and cause confusion. On 2 Feb 2023, at 02:48, EMSR @.***> wrote: @shanggl commented on this pull request. In src/main/drivers/sdcard/sdmmc_sdio.h:

ok, comments will use english as default ,

@DzikuVx DzikuVx added this to the 6.1 milestone Feb 3, 2023
@DusKing1
Copy link
Contributor Author

DusKing1 commented Feb 7, 2023

It seems that MSC is not working

shanggl and others added 5 commits February 13, 2023 00:49
Co-Authored-By: EMSR <10240646+shanggl@users.noreply.github.com>
Co-Authored-By: carl <101383042+tcdddd@users.noreply.github.com>
Co-Authored-By: Hugo Chiang <hugo@gyroflow.xyz>
Co-Authored-By: EMSR <10240646+shanggl@users.noreply.github.com>
Co-Authored-By: carl <101383042+tcdddd@users.noreply.github.com>
Co-Authored-By: Hugo Chiang <hugo@gyroflow.xyz>
Co-Authored-By: EMSR <10240646+shanggl@users.noreply.github.com>
Co-Authored-By: carl <101383042+tcdddd@users.noreply.github.com>
Co-Authored-By: Hugo Chiang <hugo@gyroflow.xyz>
Co-Authored-By: carl <101383042+tcdddd@users.noreply.github.com>
Co-Authored-By: Hugo Chiang <hugo@gyroflow.xyz>
NEUTRONRCF435AIO - based on AT32F435RGT7
NEUTRONRCF435MINI - based on AT32F435CGU7
NEUTRONRCF435WING - based on AT32F435CGU7

Co-Authored-By: EMSR <10240646+shanggl@users.noreply.github.com>
Co-Authored-By: carl <101383042+tcdddd@users.noreply.github.com>
Co-Authored-By: Hugo Chiang <hugo@gyroflow.xyz>
@DusKing1
Copy link
Contributor Author

We've cleaned all non-English comments in the code.

@DzikuVx DzikuVx changed the base branch from master to release_6.1.0 March 14, 2023 20:32
@DzikuVx DzikuVx merged commit 79840a7 into iNavFlight:release_6.1.0 Mar 23, 2023
@DusKing1 DusKing1 deleted the add-at32-bsp branch March 24, 2023 00:48
@ujara
Copy link

ujara commented Oct 8, 2023

Please add support for SD Card as it helps in tuning target.

@ujara
Copy link

ujara commented Oct 8, 2023

Also noticed in latest inav 6.1.1 release, i2C1 using ports PB6, PB7 not working for AT32F435 target. Need to hack/change "drivers/bus_i2c_at32f43x.c" for i2c1 to be mux4. In the code its mux8. This allows i2C1 to function correctly on a AT32F435 target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants