From: Green Wan <green.wan@sifive.com> Cc: alistair23@gmail.com, bmeng.cn@gmail.com, qemu-riscv@nongnu.org, qemu-devel@nongnu.org, green.wan@sifive.com Subject: [PATCH v8 0/2] Add file-backed and write-once features to OTP Date: Tue, 20 Oct 2020 11:37:30 +0800 [thread overview] Message-ID: <20201020033732.12921-1-green.wan@sifive.com> (raw) patch [1/2] - add write function and wrire-once feature patch [2/2] - add file backend support Test Steps: (should work even only 1/2 is applied) 1) Follow instructions to prepare fw_payload - https://github.com/riscv/opensbi/blob/master/docs/platform/sifive_fu540.md a) build 1-round opensbi $ cd opensbi $ OBJCOPY=riscv64-buildroot-linux-gnu-objcopy \ LD=riscv64-buildroot-linux-gnu-ld \ CC=riscv64-buildroot-linux-gnu-gcc \ make PLATFORM=sifive/fu540 b) build u-boot # Make sure the 'CONFIG_SIFIVE_OTP=y' is set $ cd u-boot $ OPENSBI=/xxx/opensbi/build/platform/sifive/fu540/firmware/fw_dynamic.bin \ ARCH=riscv \ CROSS_COMPILE=riscv64-buildroot-linux-gnu- \ make c) generate fw_payload.elf $ cd opensbi $ OBJCOPY=riscv64-buildroot-linux-gnu-objcopy \ LD=riscv64-buildroot-linux-gnu-ld \ CC=riscv64-buildroot-linux-gnu-gcc \ make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=/xxx/u-boot/u-boot.bin 2) Apply uboot test patch - http://patchwork.ozlabs.org/project/uboot/patch/1602657292-82815-1-git-send-email-bmeng.cn@gmail.com/ Rebuild u-boot and fw_payload.elf 3) Generate empty otp image. (skip this if only 1/2 is applied.) $ dd if=/dev/zero of=./otp.img bs=1k count=16 4) run qemu with fw_payload.elf $ qemu-system-riscv64 -M sifive_u -m 256M -nographic -bios none \ -kernel ../opensbi/build/platform/sifive/fu540/firmware/fw_payload.elf \ -d guest_errors -drive if=none,format=raw,file=otp.img 5) (uboot otp driver should do some read/write already) Run read/write in u-boot # dump mem before test => md 80200000 10 80200000: 84ae822a 00061297 7642b283 10529073 *.........Bvs.R. 80200010: 10401073 031b52c1 13134010 71330153 s.@..R...@..S.3q 80200020: 850a0053 28c0b0ef 812a81aa 00062297 S......(..*..".. 80200030: 94c2b283 a92f4905 16630862 22970209 .....I/.b.c...." => md 80400000 10 80400000: 00000000 00000000 00000000 00000000 ................ 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ # check read function and see if serial is set => misc read otp@10070000 3f0 80400000 10 => md 80400000 10 80400000: 00000001 fffffffe 00000000 00000000 ................ 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ # check write function => misc write otp@10070000 0 80200000 10 => misc read otp@10070000 0 80400000 10 => md 80400000 10 80400000: 84ae822a 00061297 7642b283 10529073 *.........Bvs.R. 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ => Changelogs: v6 to v7: - Rebase to the latest and move debug message patch from patch [2/2] to [1/2] - Remove RFC tag and add credit v6 to v7: - Fix bug in MACRO, SET_FUSEARRAY_BIT. - Add serial initialization in sifive_u_otp_reset(). - revise write-once error message. v5 to v6: - Rebase to latest. (sifive_u_otp.* are moved to hw/misc) - Put the example command to commit message. - Refine errp handle when check backend drive. - Remove unnecessary debug message. v4 to v5: - Change the patch order - Add write operation to update pdin to fuse[] bit by bit - Fix wrong protection for offset 0x0~0x38 - Add SIFIVE_U_OTP_PWE_EN definition - Refine access macro for fuse[] and fuse_wo[] Summary of Patches - First patch is to add write opertion to update pdin data to fuse[] bit by bit. Add 'write-once' feature to block second write to same bit of the OTP memory. - Second patch is to add file-backed implementation to allow users to use '-drive' to assign an OTP raw image file. OTP image file must be bigger than 16K. For example, '-drive if=none,format=raw,file=otp.img' Testing - Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/misc/sifive_u_otp: Add write function and write-once protection hw/misc/sifive_u_otp: Add backend drive support hw/misc/sifive_u_otp.c | 95 +++++++++++++++++++++++++++++++++- include/hw/misc/sifive_u_otp.h | 5 ++ 2 files changed, 99 insertions(+), 1 deletion(-) -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Green Wan <green.wan@sifive.com> Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, bmeng.cn@gmail.com, alistair23@gmail.com, green.wan@sifive.com Subject: [PATCH v8 0/2] Add file-backed and write-once features to OTP Date: Tue, 20 Oct 2020 11:37:30 +0800 [thread overview] Message-ID: <20201020033732.12921-1-green.wan@sifive.com> (raw) patch [1/2] - add write function and wrire-once feature patch [2/2] - add file backend support Test Steps: (should work even only 1/2 is applied) 1) Follow instructions to prepare fw_payload - https://github.com/riscv/opensbi/blob/master/docs/platform/sifive_fu540.md a) build 1-round opensbi $ cd opensbi $ OBJCOPY=riscv64-buildroot-linux-gnu-objcopy \ LD=riscv64-buildroot-linux-gnu-ld \ CC=riscv64-buildroot-linux-gnu-gcc \ make PLATFORM=sifive/fu540 b) build u-boot # Make sure the 'CONFIG_SIFIVE_OTP=y' is set $ cd u-boot $ OPENSBI=/xxx/opensbi/build/platform/sifive/fu540/firmware/fw_dynamic.bin \ ARCH=riscv \ CROSS_COMPILE=riscv64-buildroot-linux-gnu- \ make c) generate fw_payload.elf $ cd opensbi $ OBJCOPY=riscv64-buildroot-linux-gnu-objcopy \ LD=riscv64-buildroot-linux-gnu-ld \ CC=riscv64-buildroot-linux-gnu-gcc \ make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=/xxx/u-boot/u-boot.bin 2) Apply uboot test patch - http://patchwork.ozlabs.org/project/uboot/patch/1602657292-82815-1-git-send-email-bmeng.cn@gmail.com/ Rebuild u-boot and fw_payload.elf 3) Generate empty otp image. (skip this if only 1/2 is applied.) $ dd if=/dev/zero of=./otp.img bs=1k count=16 4) run qemu with fw_payload.elf $ qemu-system-riscv64 -M sifive_u -m 256M -nographic -bios none \ -kernel ../opensbi/build/platform/sifive/fu540/firmware/fw_payload.elf \ -d guest_errors -drive if=none,format=raw,file=otp.img 5) (uboot otp driver should do some read/write already) Run read/write in u-boot # dump mem before test => md 80200000 10 80200000: 84ae822a 00061297 7642b283 10529073 *.........Bvs.R. 80200010: 10401073 031b52c1 13134010 71330153 s.@..R...@..S.3q 80200020: 850a0053 28c0b0ef 812a81aa 00062297 S......(..*..".. 80200030: 94c2b283 a92f4905 16630862 22970209 .....I/.b.c...." => md 80400000 10 80400000: 00000000 00000000 00000000 00000000 ................ 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ # check read function and see if serial is set => misc read otp@10070000 3f0 80400000 10 => md 80400000 10 80400000: 00000001 fffffffe 00000000 00000000 ................ 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ # check write function => misc write otp@10070000 0 80200000 10 => misc read otp@10070000 0 80400000 10 => md 80400000 10 80400000: 84ae822a 00061297 7642b283 10529073 *.........Bvs.R. 80400010: 00000000 00000000 00000000 00000000 ................ 80400020: 00000000 00000000 00000000 00000000 ................ 80400030: 00000000 00000000 00000000 00000000 ................ => Changelogs: v6 to v7: - Rebase to the latest and move debug message patch from patch [2/2] to [1/2] - Remove RFC tag and add credit v6 to v7: - Fix bug in MACRO, SET_FUSEARRAY_BIT. - Add serial initialization in sifive_u_otp_reset(). - revise write-once error message. v5 to v6: - Rebase to latest. (sifive_u_otp.* are moved to hw/misc) - Put the example command to commit message. - Refine errp handle when check backend drive. - Remove unnecessary debug message. v4 to v5: - Change the patch order - Add write operation to update pdin to fuse[] bit by bit - Fix wrong protection for offset 0x0~0x38 - Add SIFIVE_U_OTP_PWE_EN definition - Refine access macro for fuse[] and fuse_wo[] Summary of Patches - First patch is to add write opertion to update pdin data to fuse[] bit by bit. Add 'write-once' feature to block second write to same bit of the OTP memory. - Second patch is to add file-backed implementation to allow users to use '-drive' to assign an OTP raw image file. OTP image file must be bigger than 16K. For example, '-drive if=none,format=raw,file=otp.img' Testing - Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/misc/sifive_u_otp: Add write function and write-once protection hw/misc/sifive_u_otp: Add backend drive support hw/misc/sifive_u_otp.c | 95 +++++++++++++++++++++++++++++++++- include/hw/misc/sifive_u_otp.h | 5 ++ 2 files changed, 99 insertions(+), 1 deletion(-) -- 2.17.1
next reply other threads:[~2020-10-20 3:39 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-20 3:37 Green Wan [this message] 2020-10-20 3:37 ` [PATCH v8 0/2] Add file-backed and write-once features to OTP Green Wan 2020-10-20 3:37 ` [PATCH v8 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection Green Wan 2020-10-20 3:37 ` Green Wan 2020-10-20 3:37 ` [PATCH v8 2/2] hw/misc/sifive_u_otp: Add backend drive support Green Wan 2020-10-20 3:37 ` Green Wan 2020-10-22 18:30 ` Alistair Francis 2020-10-22 18:30 ` Alistair Francis
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201020033732.12921-1-green.wan@sifive.com \ --to=green.wan@sifive.com \ --cc=alistair23@gmail.com \ --cc=bmeng.cn@gmail.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-riscv@nongnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.