Commit 111a0dc61a72e31fc7f6612e5ff70a5eb4008a0d

Authored by Nicolai Buchwitz
1 parent 49b873c1

Skip devices which don't match filter criteria

Move the port and path filter match logic up to prevent rpiboot from
loading any files if the device does not meet the given criteria.
For devices that should be ignored, the current implementation generates
numerous messages such as "Loading embedded: bootcode.bin."
Because the check occurs AFTER the filters have been evaluated, file
handling takes place even for ignored devices.

Signed-off-by: Nicolai Buchwitz <n.buchwitz@kunbus.com>
Showing 1 changed file with 18 additions and 15 deletions
... ... @@ -132,7 +132,23 @@ libusb_device_handle * LIBUSB_CALL open_device_with_vid(
132 132 const char *second_stage;
133 133  
134 134 if(verbose == 2)
135   - printf("Found candidate Compute Module...");
  135 + printf("Found candidate Compute Module...\n");
  136 +
  137 + // Check if we should match against a specific port number or path
  138 + if ((targetPortNo == 99 || portNo == targetPortNo) &&
  139 + (targetpathname == NULL || strcmp(targetpathname, pathname) == 0))
  140 + {
  141 + if(verbose)
  142 + printf("Device located successfully\n");
  143 + found = dev;
  144 + }
  145 + else
  146 + {
  147 + if(verbose == 2)
  148 + printf("Device port / path does not match, trying again\n");
  149 +
  150 + continue;
  151 + }
136 152  
137 153 bcm2711 = (desc.idProduct == 0x2711);
138 154 if (bcm2711)
... ... @@ -169,21 +185,8 @@ libusb_device_handle * LIBUSB_CALL open_device_with_vid(
169 185 if (fp_sign)
170 186 fclose(fp_sign);
171 187  
172   - ///////////////////////////////////////////////////////////////////////
173   - // Check if we should match against a specific port number
174   - ///////////////////////////////////////////////////////////////////////
175   - if ((targetPortNo == 99 || portNo == targetPortNo) &&
176   - (targetpathname==NULL||strcmp(targetpathname,pathname)==0))
177   - {
178   - if(verbose) printf("Device located successfully\n");
179   - found = dev;
  188 + if (found)
180 189 break;
181   - }
182   - else
183   - {
184   - if(verbose == 2)
185   - printf("...Wrong Port/Path, Trying again\n");
186   - }
187 190 }
188 191 }
189 192 }
... ...