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

Script for generating SVD and C-headers #25

Merged
merged 46 commits into from
Aug 1, 2021
Merged

Conversation

Yangff
Copy link
Contributor

@Yangff Yangff commented Jul 20, 2021

Hi, I create a simple script to generate SVD and headers for all peripherals under 0x44XXXXXX based on all currently knowledges.

I havn't try compile it and it may contain errors for both offset, naming and generated code.

SVD can be imported into ghidra to produce a little more readable code, although mask the real address might cause problem. Or maybe used for svd2rust. I only generated <peripheral> but you only need to merge it with original bl602 svd.

But, I cannot guarantte the correctness of these code..

It contains some research notes from This Documents.

And, mac_pl is from alios, based on my observation, it should be the same including the offset. While mac_core and ipc is from here.
and here.

Others are mainly my guess.

Beside that, it should be pretty simple to add more generate for markdown or other uses.

Usage

extarct related functions

This step allow you to isolate interested function that access certain addresses for you to analyse.

Place the ghidra decompiled C code into ./blobs/bl602_demo_wifi.ghidra.c, ensure that NO SVD is imported.
Make sure you have ctags installed.

./extract_funcs.sh | ./getfuncs.py [Intreasted Address, e.g. DAT_44c0] > somefile.c

And you can now open somefile.c to see the result.

Update it with your research and generate the result

Open manualext.py, modify it in a way you prefer and run it.

It's straightforward.

  • Use Peripheral(peripheral('name', address, size)) to define a new peripheral.
  • Use Reg(name, address) to define a reg
  • Use Field(name, mask) to define a field where the bits of that field is zero in the mask
  • Use FieldBit(name, bit, len=1) to define a field with lsb=bit and msb = bit+len-1
  • Use Buf(name, beginaddress, endaddress, nBytes=4) to define an array at [beginaddress, endaddress], both side included. nBytes is the sizeof each item.
  • Use GenSVD() to generate SVD for current peripheral.
  • Use GenHeader to generate C header for cuurent peripheral.

@gamelaster
Copy link
Member

Hi @Yangff
Really great job! Is this final commit, or you plan to add more things?

Also, I can give you an access to nutcracker repositories, so you can push things directly.

Thanks,
gamiee

@Yangff
Copy link
Contributor Author

Yangff commented Jul 23, 2021

Hi @Yangff
Really great job! Is this final commit, or you plan to add more things?

Also, I can give you an access to nutcracker repositories, so you can push things directly.

Thanks,
gamiee

I'm still adding some extra symbols. Will replay when finish

@Yangff
Copy link
Contributor Author

Yangff commented Jul 24, 2021

Hi @Yangff
Really great job! Is this final commit, or you plan to add more things?

Also, I can give you an access to nutcracker repositories, so you can push things directly.

Thanks,
gamiee

it should contain all possible symbols for now, not sure if it's correct but I think it can merge now.

I will try replacing existed objects to get some lower level rewrite code. But I'm not sure what to do about higher level like 80211 or even IPs..

@Yangff
Copy link
Contributor Author

Yangff commented Jul 26, 2021

@gamelaster
Copy link
Member

@Yangff thanks!

@gamelaster gamelaster merged commit 343bb90 into pine64:master Aug 1, 2021
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.

None yet

2 participants