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

feat(utk): Add CLI flag -erase-polarity #358

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

xaionaro
Copy link
Member

ITS: #356

Before

xaionaro@void:~/go/src/github.com/linuxboot/fiano$ dd if=/dev/zero of=/tmp/image bs=1K count=64
64+0 records in
64+0 records out
65536 bytes (66 kB, 64 KiB) copied, 0.001032 s, 63.5 MB/s
xaionaro@void:~/go/src/github.com/linuxboot/fiano$ go run ./cmds/utk/ /tmp/image create-fv $((32 * 1024)) $((32 * 1024-16)) "61C0F511-A691-4F54-974F-B9A42172CE53" save /tmp/new_image
2022/01/17 21:12:43 [fiano][FATAL] building ExtHeader erase polarity not 0x00 or 0xFF, got 0xf0
exit status 1

After

xaionaro@void:~/go/src/github.com/linuxboot/fiano$ dd if=/dev/zero of=/tmp/image bs=1K count=64
64+0 records in
64+0 records out
65536 bytes (66 kB, 64 KiB) copied, 0.00095363 s, 68.7 MB/s
xaionaro@void:~/go/src/github.com/linuxboot/fiano$ go run ./cmds/utk/ -erase-polarity=0xFF /tmp/image create-fv $((32 * 1024)) $((32 * 1024-16)) "61C0F511-A691-4F54-974F-B9A42172CE53" save /tmp/new_image
xaionaro@void:~/go/src/github.com/linuxboot/fiano$ hexdump -C /tmp/new_image
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00008010  78 e5 8c 8c 3d 8a 1c 4f  99 35 89 61 85 c3 2d d3  |x...=..O.5.a..-.|
00008020  f0 7f 00 00 00 00 00 00  5f 46 56 48 ff fe 04 00  |........_FVH....|
00008030  48 00 78 66 60 00 00 02  07 00 00 00 00 10 00 00  |H.xf`...........|
00008040  00 00 00 00 00 00 00 00  ff ff ff ff ff ff ff ff  |................|
00008050  ff ff ff ff ff ff ff ff  f4 aa f0 00 2c 00 00 f8  |............,...|
00008060  11 f5 c0 61 91 a6 54 4f  97 4f b9 a4 21 72 ce 53  |...a..TO.O..!r.S|
00008070  14 00 00 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00008080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
0000fff0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00010000

@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2022

Codecov Report

Merging #358 (0a8e8d1) into master (3c38bba) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #358   +/-   ##
=======================================
  Coverage   41.69%   41.69%           
=======================================
  Files         110      110           
  Lines        7642     7642           
=======================================
  Hits         3186     3186           
  Misses       3877     3877           
  Partials      579      579           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c38bba...0a8e8d1. Read the comment docs.

cmds/utk/utk.go Outdated

switch {
case *erasePolarityFlag == "":
case strings.HasPrefix(*erasePolarityFlag, "0x"):
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to do this. If you do strconv.ParseUint with a base of 0, it will detect the base automatically and include support for stuff like Octal (not that I'm sure anyone should attempt to supply it in Octal :P)

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow. Didn't know that. Thanks, will fix!

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

cmds/utk/utk.go Outdated
if err != nil {
return config{}, nil, fmt.Errorf("unable to parse erase polarity '%s': %w", (*erasePolarityFlag)[2:], err)
}
cfg.ErasePolarity = &[]uint8{uint8(erasePolarity)}[0]
Copy link
Member

Choose a reason for hiding this comment

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

Is there value in ensuring the erase polarity is either 0 or 0xFF? with this we could supply 0xDE if we wanted to. I'm ok either way

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok!

@xaionaro xaionaro force-pushed the feature/utk/add-erase-polarity-flag branch from 72d0b42 to bd4db7b Compare January 18, 2022 17:51
GanShun
GanShun previously approved these changes Mar 22, 2022
@orangecms orangecms added the automerge might automerge if forces align label Mar 22, 2022
@orangecms orangecms merged commit df36a56 into master Mar 22, 2022
@orangecms orangecms deleted the feature/utk/add-erase-polarity-flag branch March 22, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge might automerge if forces align
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants