Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Schauer Marin Rodrigues
reform
Commits
ae71dc2a
Verified
Commit
ae71dc2a
authored
1 year ago
by
Johannes Schauer Marin Rodrigues
Browse files
Options
Downloads
Patches
Plain Diff
reform2-lpc-fw/flash.sh: make script interactive
parent
4ecf2eab
No related branches found
No related tags found
No related merge requests found
Pipeline
#1481
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
reform2-lpc-fw/flash.sh
+62
-7
62 additions, 7 deletions
reform2-lpc-fw/flash.sh
with
62 additions
and
7 deletions
reform2-lpc-fw/flash.sh
+
62
−
7
View file @
ae71dc2a
#!/bin/
ba
sh
#!/bin/sh
set
-e
set
-e
u
# replace the x with the drive that LPC actually shows up as (check dmesg -w when plugging in)
#
#mount /dev/sdx /mnt
dd
if
=
bin/firmware.bin
of
=
"/mnt/firmware.bin"
conv
=
nocreat,notrunc
if
[
!
-e
./bin/firmware.bin
]
;
then
echo
"./bin/firmware.bin doesn't exist"
>
&2
exit
1
fi
if
[
"
$(
id
-u
)
"
-ne
0
]
;
then
echo
"you need to run this as root (for example by using sudo)"
>
&2
exit
1
fi
disk
=
"/dev/disk/by-id/usb-NXP_LPC1XXX_IFLASH_ISP-0:0"
if
[
!
-e
"
$disk
"
]
;
then
echo
'Set the DIP switch LPCPROG to “ON”.'
>
&2
echo
'Press the button LPCRESET.'
>
&2
echo
'Connect the USB cable.'
>
&2
fi
if
[
"
$(
udevadm
--version
)
"
-lt
251
]
;
then
echo
'Press the Enter key once you are ready'
>
&2
# shellcheck disable=SC2034
read
-r
enter
else
echo
'Waiting for the disk to appear...'
>
&2
udevadm
wait
--settle
"
$disk
"
fi
if
[
"
$(
udevadm info
--query
=
property
--property
=
ID_MODEL_ID
--value
"
$disk
"
)
"
!=
"000b"
]
;
then
echo
"unexpected model id"
>
&2
exit
1
fi
if
[
"
$(
udevadm info
--query
=
property
--property
=
ID_VENDOR_ID
--value
"
$disk
"
)
"
!=
"1fc9"
]
;
then
echo
"unexpected vendor id"
>
&2
exit
1
fi
if
[
"
$(
udevadm info
--query
=
property
--property
=
ID_MODEL
--value
"
$disk
"
)
"
!=
"LPC1XXX_IFLASH"
]
;
then
echo
"unexpected model"
>
&2
exit
1
fi
if
[
"
$(
udevadm info
--query
=
property
--property
=
ID_VENDOR
--value
"
$disk
"
)
"
!=
"NXP"
]
;
then
echo
"unexpected vendor"
>
&2
exit
1
fi
MOUNTPOINT
=
"
$(
mktemp
--tmpdir
--directory
reform-lpc-fw.XXXXXXXXXX
)
"
trap
'umount $MOUNTPOINT'
EXIT INT TERM
mount
"
$disk
"
"
$MOUNTPOINT
"
dd
if
=
bin/firmware.bin
of
=
"
$MOUNTPOINT
/firmware.bin"
conv
=
nocreat,notrunc
sync
umount
"/mnt"
umount
"
$MOUNTPOINT
"
trap
- EXIT INT TERM
echo
"Firmware successfully flashed."
>
&2
echo
"Unplug the Micro—USB cable."
>
&2
if
[
"
$(
udevadm
--version
)
"
-ge
251
]
;
then
udevadm
wait
--removed
"
$disk
"
fi
echo
'Set the DIP switch LPCPROG to “OFF”.'
>
&2
echo
'Press the button LPCRESET.'
>
&2
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment