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

scripts: add a script to fix gigadevice firmwares libs #19

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

feilongfl
Copy link
Contributor

@feilongfl feilongfl commented Mar 15, 2022

I learned the usage of coccinelle today and found that it is very suitable for migrate gigadevice libs to hal-gigadevice.
I think it will be very useful when add firmwares for new chip


  • download and uncompress code from gigadevice website
  • add / remove hal
  • patch the code
    • add GD32_ prefix for CAN_XXX_MODE and CAN_TIMEOUT marco
    • remove nvic_vector_table_set function call
    • add #ifndef to BIT marco
    • change timer_init to gd32_timer_init
    • add I2CCLK_MAX, I2CCLK_MIN,I2CCLK_FM_MIN,I2CCLK_FM_PLUS_MIN in xxxx_i2c.h
      drop I2CCLK_MAX, I2CCLK_MIN in xxxx_i2c.c

@feilongfl feilongfl changed the title scripts: add a script to fix gigadevice libs scripts: add a script to fix gigadevice firmwares libs Mar 15, 2022
.gitignore Outdated Show resolved Hide resolved
scripts/lib_refactor/README.md Show resolved Hide resolved
@nandojve nandojve requested a review from gmarull March 30, 2022 11:29
@@ -0,0 +1,27 @@
#!/usr/bin/env fish
Copy link
Member

Choose a reason for hiding this comment

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

note: we should be using a common shell, ie bash.

@nandojve
Copy link
Member

Hi @feilongfl,

Did you have time to review our comments?

@feilongfl
Copy link
Contributor Author

feilongfl commented Jun 26, 2022

fixed

@nandojve nandojve requested a review from gmarull July 4, 2022 16:00
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

Make sure all needed fixes are applied, see 48a1b67

Comment on lines 5 to 9
## Dependencies

```
apt install fish
```
Copy link
Member

Choose a reason for hiding this comment

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

why do we need another shell to run refactor scripts?

Comment on lines 3 to 15
if [ $# -ne 2 ]
then
echo "arguments error"
exit
fi

source_file=$2
cocci=$1

echo cocci: $cocci
echo source: $source_file

spatch -cocci_file $cocci $source_file | patch $source_file -
Copy link
Member

Choose a reason for hiding this comment

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

why not run this line directly?

Comment on lines 3 to 7
if [ $# -ne 1 ]
then
echo "arguments error"
exit
fi
Copy link
Member

Choose a reason for hiding this comment

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

please provide better error messages

mkdir gd32c10x
unrar x /tmp/gd32c10x.rar gd32c10x
mv gd32c10x/*/* gd32c10x/
scripts/lib_refactor/make_new_hal.sh gd32c10x
Copy link
Member

Choose a reason for hiding this comment

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

lib_refactor isn't probably a good name if it adds scripts to add a new HAL. I think that we should just provide a script to add a HAL (or update, which means remove and add), such script should also run patch scripts under the hood.

In fact, all the steps above could be handled by the script itself (download, uncompress, copy/delete, patch).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a preliminary version and wanted to check if it meets your expectations.
Contains download, decompression, patch functions.

I'm not sure if it makes sense to remove hal.

@nandojve
Copy link
Member

nandojve commented Aug 7, 2022

Is this PR ready for review ?

@feilongfl
Copy link
Contributor Author

feilongfl commented Aug 7, 2022

Is this PR ready for review ?

I think I need a little more time to implement the download and add/delete hal functions.

@feilongfl feilongfl force-pushed the dev-cocci branch 2 times, most recently from 7525b89 to eec38d3 Compare August 7, 2022 21:50
@feilongfl feilongfl requested a review from gmarull August 7, 2022 21:51
@feilongfl feilongfl force-pushed the dev-cocci branch 3 times, most recently from 883b8e9 to a1c65ef Compare August 9, 2022 22:18
gd32e10x: update HAL to v1.3.0

Signed-off-by: YuLong Yao <[email protected]>
apply fllowing patches for hal:
 - drop I2CCLK_MAX/I2CCLK_MIN
 - add `gd32_` prefix for timer_init
  - add ifdef to BIT macro
  - remove nvic_vector_table_set function call

Signed-off-by: YuLong Yao <[email protected]>
link script readme to top readme

Signed-off-by: YuLong Yao <[email protected]>
add script for auto import gigadevice hal

Signed-off-by: YuLong Yao <[email protected]>
@nandojve
Copy link
Member

You need solve conflict due to #27

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.

3 participants