@@ -18,7 +18,6 @@ import (
1818
1919const (
2020 imageDirectory = "/data"
21- imageNone = "/dev/mmcblk0p3"
2221 cdromFlag = "/sys/kernel/config/usb_gadget/g0/functions/mass_storage.disk0/lun.0/cdrom"
2322 mountDevice = "/sys/kernel/config/usb_gadget/g0/functions/mass_storage.disk0/lun.0/file"
2423 inquiryString = "/sys/kernel/config/usb_gadget/g0/functions/mass_storage.disk0/lun.0/inquiry_string"
@@ -109,16 +108,17 @@ func (s *Service) MountImage(c *gin.Context) {
109108 }
110109
111110 // mount
112- image := req .File
113- if image == "" {
114- image = imageNone
115- }
116-
117- if err := os .WriteFile (mountDevice , []byte (image ), 0o666 ); err != nil {
118- log .Errorf ("mount file %s failed: %s" , image , err )
119- rsp .ErrRsp (c , - 2 , "mount image failed" )
120- return
111+ if req .File != "" {
112+ if err := os .WriteFile (mountDevice , []byte (req .File ), 0o666 ); err != nil {
113+ log .Errorf ("mount file %s failed: %s" , req .File , err )
114+ rsp .ErrRsp (c , - 2 , "mount image failed" )
115+ return
116+ }
121117 }
118+ // When req.File is empty the device stays unmounted (no media).
119+ // Previously this wrote /dev/mmcblk0p3, exposing the NanoKVM's raw
120+ // eMMC partition as a USB disk — causing Legacy BIOS boot hangs.
121+ // See: https://github.com/sipeed/NanoKVM/issues/633
122122
123123 h := hid .GetHid ()
124124 h .Lock ()
@@ -156,8 +156,9 @@ func (s *Service) GetMountedImage(c *gin.Context) {
156156 return
157157 }
158158
159- image := strings .ReplaceAll (string (content ), "\n " , "" )
160- if image == imageNone {
159+ image := strings .TrimSpace (string (content ))
160+ if image == "/dev/mmcblk0p3" {
161+ // Backward compat: treat eMMC partition as "no image mounted"
161162 image = ""
162163 }
163164
0 commit comments