@@ -32,6 +32,7 @@ export default function LandingHero() {
3232 const textDecoderRef = useRef < TextDecoderStream | null > ( null )
3333 const readableStreamClosedRef = useRef < Promise < void > | null > ( null )
3434 const logsRef = useRef < string > ( '' )
35+ const [ keepConfig , setKeepConfig ] = useState ( false ) ;
3536
3637 useEffect ( ( ) => {
3738 const userAgent = navigator . userAgent . toLowerCase ( ) ;
@@ -116,6 +117,10 @@ export default function LandingHero() {
116117 }
117118 }
118119
120+ const handleKeepConfigToggle = ( event : React . ChangeEvent < HTMLInputElement > ) => {
121+ setKeepConfig ( event . target . checked ) ;
122+ } ;
123+
119124 const startSerialLogging = async ( ) => {
120125 if ( ! serialPortRef . current ) {
121126 setStatus ( t ( 'status.connectFirst' ) ) ;
@@ -256,11 +261,34 @@ export default function LandingHero() {
256261
257262 setStatus ( t ( 'status.flashing' , { percent : 0 } ) )
258263
264+ // On all Bitaxe derivatives the same
265+ const nvsStart = 0x9000 ;
266+ const nvsSize = 0x6000 ;
267+
268+ let parts ;
269+
270+ if ( keepConfig ) {
271+ parts = [
272+ {
273+ data : firmwareBinaryString . slice ( 0 , nvsStart ) , // Data before NVS
274+ address : 0 ,
275+ } ,
276+ {
277+ data : firmwareBinaryString . slice ( nvsStart + nvsSize ) , // Data after NVS
278+ address : nvsStart + nvsSize ,
279+ } ,
280+ ] ;
281+ } else {
282+ parts = [
283+ {
284+ data : firmwareBinaryString , // Entire firmware binary
285+ address : 0 ,
286+ } ,
287+ ] ;
288+ }
289+
259290 await loader . writeFlash ( {
260- fileArray : [ {
261- data : firmwareBinaryString ,
262- address : 0
263- } ] ,
291+ fileArray : parts ,
264292 flashSize : "keep" ,
265293 flashMode : "keep" ,
266294 flashFreq : "keep" ,
@@ -354,6 +382,18 @@ export default function LandingHero() {
354382 disabled = { isConnecting || isFlashing }
355383 />
356384 ) }
385+ < div className = "flex items-center gap-2" >
386+ < input
387+ type = "checkbox"
388+ id = "keepConfig"
389+ className = "cursor-pointer"
390+ checked = { keepConfig }
391+ onChange = { handleKeepConfigToggle }
392+ />
393+ < label htmlFor = "keepConfig" className = "text-gray-500 dark:text-gray-400 cursor-pointer" >
394+ { t ( 'hero.keepConfig' ) }
395+ </ label >
396+ </ div >
357397 < Button
358398 className = "w-full"
359399 onClick = { handleStartFlashing }
0 commit comments