tossp / redpill-tool-chain

这是一个测试项目,可能会有不可预测的事情发生(比如:毁损数据、烧毁硬件等等),请谨慎使用。
808 stars 1.89k forks source link

我想设置固定的sn、mac、vid、pid是怎么修改参数? #232

Closed Honanhui closed 1 year ago

Honanhui commented 1 year ago

我想设置固定的sn、mac、vid、pid是怎么修改参数?

调整VID和PID

      sed -i -e 's/0x0001/0x88AA/g' -e 's/0x46f4/0x88AA/g' ${{matrix.platform}}_user_config.json
      # 调整SN和MAC,最好使用 actions secrets 引入,SN应该是固定值不应该每次生成
      sn=`./redpill_tool_chain.sh sn ${{matrix.platform}} | grep 'Serial Number' | awk '{print $3}'`
      sed -i -e "s/1234XXX123/${sn:="1130LWN123456"}/g" -e 's/XXYYXXYYXXYY/0011323D47F7/g' ${{matrix.platform}}_user_config.json
      # 添加第二张网卡mac并设置网卡数量
      sed -i -e 's/0011323D47F7"/&,\n\t"mac2": "0011323D47F8",\n\t"netif_num": 2/' ${{matrix.platform}}_user_config.json

怎么修改?

tossp commented 1 year ago

这里需要一点点linux命令的知识,主要是sed命令的使用

这里的指令没截全,在你截取的这段之上还有一段https://github.com/tossp/redpill-tool-chain/blob/74736896f80cde535d5945dbc20cc48f8b2c2a1f/.github/workflows/test.yml#L96 这里可以看出 ${{matrix.platform}}_user_config.json 是复制的sample_user_config.json文件,

之后的命令就是对${{matrix.platform}}_user_config.json文件里面的字符串的匹配和修改了,简单举例两个

  1. 这里就是把PIDVID都改为了0x88AA,在sample_user_config.json文件中你能看到0x00010x46f4分别对应的是啥

    sed -i -e 's/0x0001/0x88AA/g' -e 's/0x46f4/0x88AA/g' ${{matrix.platform}}_user_config.json
  2. 同样的在sample_user_config.json文件中能看到snmac被分别固定为了1234XXX123XXYYXXYYXXYY,那就查找并修改他。其中使用到了环境的变量sn,不熟悉可以像改mac那样改为直接写死。

sed -i -e "s/1234XXX123/${sn:="1130LWN123456"}/g" -e 's/XXYYXXYYXXYY/0011323D47F7/g' ${{matrix.platform}}_user_config.json
Honanhui commented 1 year ago

谢谢啦,我试一下

发自我的 iPhone

在 2022年11月30日,07:48,TossPig @.***> 写道:



这里需要一点点linux命令的知识,主要是sed命令的使用

这里的指令没截全,在你截取的这段之上还有一段https://github.com/tossp/redpill-tool-chain/blob/74736896f80cde535d5945dbc20cc48f8b2c2a1f/.github/workflows/test.yml#L96 这里可以看出 ${{matrix.platform}}_user_config.json 是复制的sample_user_config.json文件,

之后的命令就是对${{matrix.platform}}_user_config.json文件里面的字符串的匹配和修改了,简单举例两个

  1. 这里就是把PID和VID都改为了0x88AA,在sample_user_config.jsonhttps://github.com/tossp/redpill-tool-chain/blob/master/sample_user_config.json文件中你能看到0x0001和0x46f4分别对应的是啥

sed -i -e 's/0x0001/0x88AA/g' -e 's/0x46f4/0x88AA/g' ${{matrix.platform}}_user_config.json

  1. 同样的在sample_user_config.json文件中能看到sn和mac被分别固定为了1234XXX123和XXYYXXYYXXYY,那就查找并修改他。其中使用到了环境的变量sn,不熟悉可以像改mac那样改为直接写死。

sed -i -e "s/1234XXX123/${sn:="1130LWN123456"}/g" -e 's/XXYYXXYYXXYY/0011323D47F7/g' ${{matrix.platform}}_user_config.json

— Reply to this email directly, view it on GitHubhttps://github.com/tossp/redpill-tool-chain/issues/232#issuecomment-1331464531, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYFS3VOWOIDGVW7FGT5MLGTWK2I3LANCNFSM6AAAAAASOXR3UI. You are receiving this because you authored the thread.Message ID: @.***>

Honanhui commented 1 year ago

还有个问题忘记问了,我想在添加"DiskIdxMap","SataPortMap","SasIdxMap"是怎么添加呢?不想在sample_user_config.json修改的话

tossp commented 1 year ago

https://github.com/tossp/redpill-tool-chain/blob/40a7fde12d19d1a741bc9a22fd912f2bdfb05d8c/.github/workflows/test.yml#L61-L62

Honanhui commented 1 year ago

${{ secrets.DS918_MAC }}这个是什么意思呢?我编译3622的,那样是不是918这里改成3622?

tossp commented 1 year ago

这是actions secrets变量,避免我洗白码泄露的

Honanhui commented 1 year ago

明白了

Honanhui commented 1 year ago

include/json.sh: line 16: 2: unbound variable make: *** [Makefile:34: build_redpill_load] Error 1 Error: Process completed with exit code 2. 这个错误我搞不懂。。 我按照你的方法,修改如下

添加第二张网卡mac并设置网卡数量

      sed -i -e 's/00113240D4FC"/&,\n\t"netif_num": 4/' ${{matrix.platform}}_user_config.json
      # 调整直通 PCI 的 SATA 顺序
      sed -i -e 's/4/&,\n\t"DiskIdxMap": "00",\n\t"SataPortMap": "64",\n\t"SasIdxMap": "00"/' ${{matrix.platform}}_user_config.json
tossp commented 1 year ago

你修改后的文件json语法错误

Honanhui commented 1 year ago

弄好了,谢谢大佬

发自我的 iPhone

在 2022年12月1日,11:08,TossPig @.***> 写道:



你修改后的文件json语法错误

— Reply to this email directly, view it on GitHubhttps://github.com/tossp/redpill-tool-chain/issues/232#issuecomment-1333100218, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYFS3VNAUFL6QVUJGXSNVJTWLAJDRANCNFSM6AAAAAASOXR3UI. You are receiving this because you authored the thread.Message ID: @.***>